* [PATCH] PM: sleep: Fix error handling in dpm_prepare()
@ 2021-12-16 19:30 Rafael J. Wysocki
2021-12-16 19:44 ` Thomas Hellström
2021-12-17 17:21 ` Ulf Hansson
0 siblings, 2 replies; 4+ messages in thread
From: Rafael J. Wysocki @ 2021-12-16 19:30 UTC (permalink / raw)
To: Linux PM; +Cc: Thomas Hellström, LKML, Ulf Hansson
From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
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>
Thomas Hellström <thomas.hellstrom@linux.intel.com>
---
drivers/base/power/main.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Index: linux-pm/drivers/base/power/main.c
===================================================================
--- linux-pm.orig/drivers/base/power/main.c
+++ linux-pm/drivers/base/power/main.c
@@ -1902,7 +1902,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);
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] PM: sleep: Fix error handling in dpm_prepare()
2021-12-16 19:30 [PATCH] PM: sleep: Fix error handling in dpm_prepare() Rafael J. Wysocki
@ 2021-12-16 19:44 ` Thomas Hellström
2021-12-16 19:49 ` Rafael J. Wysocki
2021-12-17 17:21 ` Ulf Hansson
1 sibling, 1 reply; 4+ messages in thread
From: Thomas Hellström @ 2021-12-16 19:44 UTC (permalink / raw)
To: Rafael J. Wysocki, Linux PM; +Cc: LKML, Ulf Hansson
On Thu, 2021-12-16 at 20:30 +0100, Rafael J. Wysocki wrote:
> From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
>
> 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>
> Thomas Hellström <thomas.hellstrom@linux.intel.com>
Was this meant to be a Reported-by:?
Also Cc stable? IIRC 2aa36604e824 was.
In any case,
Reviewed-by: Thomas Hellström <thomas.hellstrom@linux.intel.com>
Thanks,
Thomas
> ---
> drivers/base/power/main.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> Index: linux-pm/drivers/base/power/main.c
> ===================================================================
> --- linux-pm.orig/drivers/base/power/main.c
> +++ linux-pm/drivers/base/power/main.c
> @@ -1902,7 +1902,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);
>
>
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] PM: sleep: Fix error handling in dpm_prepare()
2021-12-16 19:44 ` Thomas Hellström
@ 2021-12-16 19:49 ` Rafael J. Wysocki
0 siblings, 0 replies; 4+ messages in thread
From: Rafael J. Wysocki @ 2021-12-16 19:49 UTC (permalink / raw)
To: Thomas Hellström; +Cc: Rafael J. Wysocki, Linux PM, LKML, Ulf Hansson
On Thu, Dec 16, 2021 at 8:44 PM Thomas Hellström
<thomas.hellstrom@linux.intel.com> wrote:
>
> On Thu, 2021-12-16 at 20:30 +0100, Rafael J. Wysocki wrote:
> > From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> >
> > 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>
> > Thomas Hellström <thomas.hellstrom@linux.intel.com>
>
> Was this meant to be a Reported-by:?
Yes, it was, sorry.
> Also Cc stable? IIRC 2aa36604e824 was.
That gets added later and -stable can figure it out.
> In any case,
> Reviewed-by: Thomas Hellström <thomas.hellstrom@linux.intel.com>
Thanks!
> > ---
> > drivers/base/power/main.c | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > Index: linux-pm/drivers/base/power/main.c
> > ===================================================================
> > --- linux-pm.orig/drivers/base/power/main.c
> > +++ linux-pm/drivers/base/power/main.c
> > @@ -1902,7 +1902,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);
> >
> >
> >
>
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] PM: sleep: Fix error handling in dpm_prepare()
2021-12-16 19:30 [PATCH] PM: sleep: Fix error handling in dpm_prepare() Rafael J. Wysocki
2021-12-16 19:44 ` Thomas Hellström
@ 2021-12-17 17:21 ` Ulf Hansson
1 sibling, 0 replies; 4+ messages in thread
From: Ulf Hansson @ 2021-12-17 17:21 UTC (permalink / raw)
To: Rafael J. Wysocki; +Cc: Linux PM, Thomas Hellström, LKML
On Thu, 16 Dec 2021 at 20:30, Rafael J. Wysocki <rjw@rjwysocki.net> wrote:
>
> From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
>
> 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>
> Thomas Hellström <thomas.hellstrom@linux.intel.com>
Reviewed-by: Ulf Hansson <ulf.hansson@linaro.org>
Kind regards
Uffe
> ---
> drivers/base/power/main.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> Index: linux-pm/drivers/base/power/main.c
> ===================================================================
> --- linux-pm.orig/drivers/base/power/main.c
> +++ linux-pm/drivers/base/power/main.c
> @@ -1902,7 +1902,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);
>
>
>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2021-12-17 17:21 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-16 19:30 [PATCH] PM: sleep: Fix error handling in dpm_prepare() Rafael J. Wysocki
2021-12-16 19:44 ` Thomas Hellström
2021-12-16 19:49 ` Rafael J. Wysocki
2021-12-17 17:21 ` Ulf Hansson
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.