]> Git Repo - J-linux.git/commitdiff
PM: domains: Ensure genpd_debugfs_dir exists before remove
authorHsin-Yi Wang <[email protected]>
Tue, 5 Jul 2022 17:16:49 +0000 (01:16 +0800)
committerRafael J. Wysocki <[email protected]>
Thu, 14 Jul 2022 18:50:06 +0000 (20:50 +0200)
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 <[email protected]>
Reviewed-by: Greg Kroah-Hartman <[email protected]>
Reviewed-by: AngeloGioacchino Del Regno <[email protected]>
Reviewed-by: Ulf Hansson <[email protected]>
Signed-off-by: Rafael J. Wysocki <[email protected]>
drivers/base/power/domain.c

index 739e52cd4aba5dd4b3c666ad9cbdf38120747cb5..55a10e6d4e2a755a20ae3f830103f6dec53697a1 100644 (file)
@@ -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);
 }
This page took 0.052989 seconds and 4 git commands to generate.