From: Rafael J. Wysocki Date: Thu, 16 Dec 2021 19:30:18 +0000 (+0100) Subject: PM: sleep: Fix error handling in dpm_prepare() X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=f4321ac030b54573cde3d84d49a88d49d0fc246a;p=linux.git PM: sleep: Fix error handling in dpm_prepare() commit 544e737dea5ad1a457f25dbddf68761ff25e028b upstream. 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 Reported-by: Thomas Hellström Reviewed-by: Thomas Hellström Reviewed-by: Ulf Hansson Cc: All applicable Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/base/power/main.c b/drivers/base/power/main.c index a7fdd86fad057..6bce40e2506e5 100644 --- a/drivers/base/power/main.c +++ b/drivers/base/power/main.c @@ -1906,7 +1906,7 @@ int dpm_prepare(pm_message_t state) device_block_probing(); mutex_lock(&dpm_list_mtx); - while (!list_empty(&dpm_list)) { + while (!list_empty(&dpm_list) && !error) { struct device *dev = to_device(dpm_list.next); get_device(dev);