]> git.baikalelectronics.ru Git - kernel.git/commit
PM: domains: Ensure genpd_debugfs_dir exists before remove
authorHsin-Yi Wang <hsinyi@chromium.org>
Tue, 5 Jul 2022 17:16:49 +0000 (01:16 +0800)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Thu, 14 Jul 2022 18:50:06 +0000 (20:50 +0200)
commit1e05d3514ea166225b791295da378495a164a1cc
tree3e9afdc7ed27cfc5f8f5d6754fe31765f219c356
parent487996e48b34d93836beb702e9dea5f991d1cd8a
PM: domains: Ensure genpd_debugfs_dir exists before remove

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: 6730ef58dddf ("PM: domains: create debugfs nodes when adding power domains")
Signed-off-by: Hsin-Yi Wang <hsinyi@chromium.org>
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Reviewed-by: Ulf Hansson <ulf.hansson@linaro.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
drivers/base/power/domain.c