PM: sleep: Fix error handling in dpm_prepare()
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>
Thu, 16 Dec 2021 19:30:18 +0000 (20:30 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 29 Dec 2021 11:28:38 +0000 (12:28 +0100)
commitf4321ac030b54573cde3d84d49a88d49d0fc246a
treeb9def327b67682645a4fc9b378b3fa5864b7866a
parenteabc0aab98e5218ceecd82069b0d6fdfff5ee885
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 <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>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/base/power/main.c