* [PATCH v2] PM: domains: Ensure genpd_debugfs_dir exists before remove
@ 2022-07-05 17:16 Hsin-Yi Wang
2022-07-05 17:37 ` Greg Kroah-Hartman
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Hsin-Yi Wang @ 2022-07-05 17:16 UTC (permalink / raw)
To: Greg Kroah-Hartman
Cc: Rafael J . Wysocki, Kevin Hilman, Ulf Hansson, Pavel Machek,
Len Brown, AngeloGioacchino Del Regno, Pin-yen Lin, linux-pm,
linux-kernel
Both genpd_debug_add() and genpd_debug_remove() may be called
indirectly by other drivers while genpd_debugfs_dir is not yet
set. For example, drivers can call pm_genpd_init() in probe or
pm_genpd_init() in probe fail/cleanup path:
pm_genpd_init()
--> genpd_debug_add()
pm_genpd_remove()
--> genpd_remove()
--> genpd_debug_remove()
At this time, genpd_debug_init() may not yet be called.
genpd_debug_add() checks that if genpd_debugfs_dir is NULL, it
will return directly. Make sure this is also checked
in pm_genpd_remove(), otherwise components under debugfs root
which has the same name as other components under pm_genpd may
be accidentally removed, since NULL represents debugfs root.
Fixes: 718072ceb211 ("PM: domains: create debugfs nodes when adding power domains")
Signed-off-by: Hsin-Yi Wang <hsinyi@chromium.org>
---
v1->v2: Add more context in commit message
---
drivers/base/power/domain.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c
index 3e86772d5fac5..5a2e0232862e0 100644
--- a/drivers/base/power/domain.c
+++ b/drivers/base/power/domain.c
@@ -222,6 +222,9 @@ static void genpd_debug_remove(struct generic_pm_domain *genpd)
{
struct dentry *d;
+ if (!genpd_debugfs_dir)
+ return;
+
d = debugfs_lookup(genpd->name, genpd_debugfs_dir);
debugfs_remove(d);
}
--
2.37.0.rc0.161.g10f37bed90-goog
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH v2] PM: domains: Ensure genpd_debugfs_dir exists before remove
2022-07-05 17:16 [PATCH v2] PM: domains: Ensure genpd_debugfs_dir exists before remove Hsin-Yi Wang
@ 2022-07-05 17:37 ` Greg Kroah-Hartman
2022-07-06 8:23 ` AngeloGioacchino Del Regno
2022-07-13 12:01 ` Ulf Hansson
2 siblings, 0 replies; 5+ messages in thread
From: Greg Kroah-Hartman @ 2022-07-05 17:37 UTC (permalink / raw)
To: Hsin-Yi Wang
Cc: Rafael J . Wysocki, Kevin Hilman, Ulf Hansson, Pavel Machek,
Len Brown, AngeloGioacchino Del Regno, Pin-yen Lin, linux-pm,
linux-kernel
On Wed, Jul 06, 2022 at 01:16:49AM +0800, Hsin-Yi Wang wrote:
> Both genpd_debug_add() and genpd_debug_remove() may be called
> indirectly by other drivers while genpd_debugfs_dir is not yet
> set. For example, drivers can call pm_genpd_init() in probe or
> pm_genpd_init() in probe fail/cleanup path:
>
> pm_genpd_init()
> --> genpd_debug_add()
>
> pm_genpd_remove()
> --> genpd_remove()
> --> genpd_debug_remove()
>
> At this time, genpd_debug_init() may not yet be called.
>
> genpd_debug_add() checks that if genpd_debugfs_dir is NULL, it
> will return directly. Make sure this is also checked
> in pm_genpd_remove(), otherwise components under debugfs root
> which has the same name as other components under pm_genpd may
> be accidentally removed, since NULL represents debugfs root.
>
> Fixes: 718072ceb211 ("PM: domains: create debugfs nodes when adding power domains")
> Signed-off-by: Hsin-Yi Wang <hsinyi@chromium.org>
> ---
> v1->v2: Add more context in commit message
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v2] PM: domains: Ensure genpd_debugfs_dir exists before remove
2022-07-05 17:16 [PATCH v2] PM: domains: Ensure genpd_debugfs_dir exists before remove Hsin-Yi Wang
2022-07-05 17:37 ` Greg Kroah-Hartman
@ 2022-07-06 8:23 ` AngeloGioacchino Del Regno
2022-07-13 12:01 ` Ulf Hansson
2 siblings, 0 replies; 5+ messages in thread
From: AngeloGioacchino Del Regno @ 2022-07-06 8:23 UTC (permalink / raw)
To: Hsin-Yi Wang, Greg Kroah-Hartman
Cc: Rafael J . Wysocki, Kevin Hilman, Ulf Hansson, Pavel Machek,
Len Brown, Pin-yen Lin, linux-pm, linux-kernel
Il 05/07/22 19:16, Hsin-Yi Wang ha scritto:
> Both genpd_debug_add() and genpd_debug_remove() may be called
> indirectly by other drivers while genpd_debugfs_dir is not yet
> set. For example, drivers can call pm_genpd_init() in probe or
> pm_genpd_init() in probe fail/cleanup path:
>
> pm_genpd_init()
> --> genpd_debug_add()
>
> pm_genpd_remove()
> --> genpd_remove()
> --> genpd_debug_remove()
>
> At this time, genpd_debug_init() may not yet be called.
>
> genpd_debug_add() checks that if genpd_debugfs_dir is NULL, it
> will return directly. Make sure this is also checked
> in pm_genpd_remove(), otherwise components under debugfs root
> which has the same name as other components under pm_genpd may
> be accidentally removed, since NULL represents debugfs root.
>
> Fixes: 718072ceb211 ("PM: domains: create debugfs nodes when adding power domains")
> Signed-off-by: Hsin-Yi Wang <hsinyi@chromium.org>
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v2] PM: domains: Ensure genpd_debugfs_dir exists before remove
2022-07-05 17:16 [PATCH v2] PM: domains: Ensure genpd_debugfs_dir exists before remove Hsin-Yi Wang
2022-07-05 17:37 ` Greg Kroah-Hartman
2022-07-06 8:23 ` AngeloGioacchino Del Regno
@ 2022-07-13 12:01 ` Ulf Hansson
2022-07-14 18:51 ` Rafael J. Wysocki
2 siblings, 1 reply; 5+ messages in thread
From: Ulf Hansson @ 2022-07-13 12:01 UTC (permalink / raw)
To: Hsin-Yi Wang
Cc: Greg Kroah-Hartman, Rafael J . Wysocki, Kevin Hilman,
Pavel Machek, Len Brown, AngeloGioacchino Del Regno, Pin-yen Lin,
linux-pm, linux-kernel
On Tue, 5 Jul 2022 at 19:17, Hsin-Yi Wang <hsinyi@chromium.org> wrote:
>
> Both genpd_debug_add() and genpd_debug_remove() may be called
> indirectly by other drivers while genpd_debugfs_dir is not yet
> set. For example, drivers can call pm_genpd_init() in probe or
> pm_genpd_init() in probe fail/cleanup path:
>
> pm_genpd_init()
> --> genpd_debug_add()
>
> pm_genpd_remove()
> --> genpd_remove()
> --> genpd_debug_remove()
>
> At this time, genpd_debug_init() may not yet be called.
>
> genpd_debug_add() checks that if genpd_debugfs_dir is NULL, it
> will return directly. Make sure this is also checked
> in pm_genpd_remove(), otherwise components under debugfs root
> which has the same name as other components under pm_genpd may
> be accidentally removed, since NULL represents debugfs root.
>
> Fixes: 718072ceb211 ("PM: domains: create debugfs nodes when adding power domains")
> Signed-off-by: Hsin-Yi Wang <hsinyi@chromium.org>
Reviewed-by: Ulf Hansson <ulf.hansson@linaro.org>
Kind regards
Uffe
> ---
> v1->v2: Add more context in commit message
> ---
> drivers/base/power/domain.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c
> index 3e86772d5fac5..5a2e0232862e0 100644
> --- a/drivers/base/power/domain.c
> +++ b/drivers/base/power/domain.c
> @@ -222,6 +222,9 @@ static void genpd_debug_remove(struct generic_pm_domain *genpd)
> {
> struct dentry *d;
>
> + if (!genpd_debugfs_dir)
> + return;
> +
> d = debugfs_lookup(genpd->name, genpd_debugfs_dir);
> debugfs_remove(d);
> }
> --
> 2.37.0.rc0.161.g10f37bed90-goog
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v2] PM: domains: Ensure genpd_debugfs_dir exists before remove
2022-07-13 12:01 ` Ulf Hansson
@ 2022-07-14 18:51 ` Rafael J. Wysocki
0 siblings, 0 replies; 5+ messages in thread
From: Rafael J. Wysocki @ 2022-07-14 18:51 UTC (permalink / raw)
To: Ulf Hansson, Hsin-Yi Wang
Cc: Greg Kroah-Hartman, Rafael J . Wysocki, Kevin Hilman,
Pavel Machek, Len Brown, AngeloGioacchino Del Regno, Pin-yen Lin,
Linux PM, Linux Kernel Mailing List
On Wed, Jul 13, 2022 at 2:02 PM Ulf Hansson <ulf.hansson@linaro.org> wrote:
>
> On Tue, 5 Jul 2022 at 19:17, Hsin-Yi Wang <hsinyi@chromium.org> wrote:
> >
> > Both genpd_debug_add() and genpd_debug_remove() may be called
> > indirectly by other drivers while genpd_debugfs_dir is not yet
> > set. For example, drivers can call pm_genpd_init() in probe or
> > pm_genpd_init() in probe fail/cleanup path:
> >
> > pm_genpd_init()
> > --> genpd_debug_add()
> >
> > pm_genpd_remove()
> > --> genpd_remove()
> > --> genpd_debug_remove()
> >
> > At this time, genpd_debug_init() may not yet be called.
> >
> > genpd_debug_add() checks that if genpd_debugfs_dir is NULL, it
> > will return directly. Make sure this is also checked
> > in pm_genpd_remove(), otherwise components under debugfs root
> > which has the same name as other components under pm_genpd may
> > be accidentally removed, since NULL represents debugfs root.
> >
> > Fixes: 718072ceb211 ("PM: domains: create debugfs nodes when adding power domains")
> > Signed-off-by: Hsin-Yi Wang <hsinyi@chromium.org>
>
> Reviewed-by: Ulf Hansson <ulf.hansson@linaro.org>
Applied as 5.20 material, thanks!
> > ---
> > v1->v2: Add more context in commit message
> > ---
> > drivers/base/power/domain.c | 3 +++
> > 1 file changed, 3 insertions(+)
> >
> > diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c
> > index 3e86772d5fac5..5a2e0232862e0 100644
> > --- a/drivers/base/power/domain.c
> > +++ b/drivers/base/power/domain.c
> > @@ -222,6 +222,9 @@ static void genpd_debug_remove(struct generic_pm_domain *genpd)
> > {
> > struct dentry *d;
> >
> > + if (!genpd_debugfs_dir)
> > + return;
> > +
> > d = debugfs_lookup(genpd->name, genpd_debugfs_dir);
> > debugfs_remove(d);
> > }
> > --
> > 2.37.0.rc0.161.g10f37bed90-goog
> >
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2022-07-14 18:52 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-05 17:16 [PATCH v2] PM: domains: Ensure genpd_debugfs_dir exists before remove Hsin-Yi Wang
2022-07-05 17:37 ` Greg Kroah-Hartman
2022-07-06 8:23 ` AngeloGioacchino Del Regno
2022-07-13 12:01 ` Ulf Hansson
2022-07-14 18:51 ` Rafael J. Wysocki
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).