[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20220705094946.827697-1-hsinyi@chromium.org>
Date: Tue, 5 Jul 2022 17:49:47 +0800
From: Hsin-Yi Wang <hsinyi@...omium.org>
To: "Rafael J . Wysocki" <rafael@...nel.org>
Cc: Kevin Hilman <khilman@...nel.org>,
Ulf Hansson <ulf.hansson@...aro.org>,
Len Brown <len.brown@...el.com>, Pavel Machek <pavel@....cz>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Thierry Strudel <tstrudel@...gle.com>,
linux-pm@...r.kernel.org, linux-kernel@...r.kernel.org,
AngeloGioacchino Del Regno
<angelogioacchino.delregno@...labora.com>,
Pin-yen Lin <treapking@...omium.org>
Subject: [PATCH] PM: domains: Ensure genpd_debugfs_dir exists before remove
genpd_debug_remove() may be indirectly called from others while
genpd_debugfs_dir is not yet set. Make sure genpd_debugfs_dir exists
before remove the sub components, otherwise components under
/sys/kernel/debug may be accidentally removed.
Fixes: 718072ceb211 ("PM: domains: create debugfs nodes when adding power domains")
Signed-off-by: Hsin-Yi Wang <hsinyi@...omium.org>
---
An example:
scpsys_probe() in drivers/soc/mediatek/mtk-pm-domains.c indirectly calls
genpd_debug_remove() on probe fail, causing /sys/kernel/debug/usb to be
removed.
---
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
Powered by blists - more mailing lists