Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

PM: sleep: Fix error handling in dpm_prepare()

Commit 2aa36604e824 ("PM: sleep: Avoid calling put_device() under
dpm_list_mtx") forgot to update the while () loop termination
condition to also break the loop if error is nonzero, which
causes the loop to become infinite if device_prepare() returns
an error for one device.

Add the missing !error check.

Fixes: 2aa36604e824 ("PM: sleep: Avoid calling put_device() under dpm_list_mtx")
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Reported-by: Thomas Hellström <thomas.hellstrom@linux.intel.com>
Reviewed-by: Thomas Hellström <thomas.hellstrom@linux.intel.com>
Reviewed-by: Ulf Hansson <ulf.hansson@linaro.org>
Cc: All applicable <stable@vger.kernel.org>

+1 -1
+1 -1
drivers/base/power/main.c
··· 1902 1902 device_block_probing(); 1903 1903 1904 1904 mutex_lock(&dpm_list_mtx); 1905 - while (!list_empty(&dpm_list)) { 1905 + while (!list_empty(&dpm_list) && !error) { 1906 1906 struct device *dev = to_device(dpm_list.next); 1907 1907 1908 1908 get_device(dev);