diff mbox series

clk: mmp2: call pm_genpd_init() only after genpd.name is set

Message ID 20241231190336.423172-1-lkundrak@v3.sk (mailing list archive)
State Accepted, archived
Headers show
Series clk: mmp2: call pm_genpd_init() only after genpd.name is set | expand

Commit Message

Lubomir Rintel Dec. 31, 2024, 7:03 p.m. UTC
Setting the genpd's struct device's name with dev_set_name() is
happening within pm_genpd_init(). If it remains NULL, things can blow up
later, such as when crafting the devfs hierarchy for the power domain:

  8<--- cut here --- [please do not actually cut, you'll ruin your display]
  Unable to handle kernel NULL pointer dereference at virtual address 00000000 when read
  ...
  Call trace:
   strlen from start_creating+0x90/0x138
   start_creating from debugfs_create_dir+0x20/0x178
   debugfs_create_dir from genpd_debug_add.part.0+0x4c/0x144
   genpd_debug_add.part.0 from genpd_debug_init+0x74/0x90
   genpd_debug_init from do_one_initcall+0x5c/0x244
   do_one_initcall from kernel_init_freeable+0x19c/0x1f4
   kernel_init_freeable from kernel_init+0x1c/0x12c
   kernel_init from ret_from_fork+0x14/0x28

Bisecting tracks this crash back to commit 899f44531fe6 ("pmdomain: core:
Add GENPD_FLAG_DEV_NAME_FW flag"), which exchanges use of genpd->name
with dev_name(&genpd->dev) in genpd_debug_add.part().

Fixes: 899f44531fe6 ("pmdomain: core: Add GENPD_FLAG_DEV_NAME_FW flag")
Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
Cc: stable@vger.kernel.org # v6.12+
---
 drivers/clk/mmp/pwr-island.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Stephen Boyd Jan. 7, 2025, 9:36 p.m. UTC | #1
Quoting Lubomir Rintel (2024-12-31 11:03:35)
> Setting the genpd's struct device's name with dev_set_name() is
> happening within pm_genpd_init(). If it remains NULL, things can blow up
> later, such as when crafting the devfs hierarchy for the power domain:
> 
>   8<--- cut here --- [please do not actually cut, you'll ruin your display]

Applied to clk-fixes
Stephen Boyd Jan. 7, 2025, 9:37 p.m. UTC | #2
Quoting Lubomir Rintel (2024-12-31 11:03:35)
> Setting the genpd's struct device's name with dev_set_name() is
> happening within pm_genpd_init(). If it remains NULL, things can blow up
> later, such as when crafting the devfs hierarchy for the power domain:
> 
>   8<--- cut here --- [please do not actually cut, you'll ruin your display]
>   Unable to handle kernel NULL pointer dereference at virtual address 00000000 when read
>   ...
>   Call trace:
>    strlen from start_creating+0x90/0x138
>    start_creating from debugfs_create_dir+0x20/0x178
>    debugfs_create_dir from genpd_debug_add.part.0+0x4c/0x144
>    genpd_debug_add.part.0 from genpd_debug_init+0x74/0x90
>    genpd_debug_init from do_one_initcall+0x5c/0x244
>    do_one_initcall from kernel_init_freeable+0x19c/0x1f4
>    kernel_init_freeable from kernel_init+0x1c/0x12c
>    kernel_init from ret_from_fork+0x14/0x28
> 
> Bisecting tracks this crash back to commit 899f44531fe6 ("pmdomain: core:
> Add GENPD_FLAG_DEV_NAME_FW flag"), which exchanges use of genpd->name
> with dev_name(&genpd->dev) in genpd_debug_add.part().
> 
> Fixes: 899f44531fe6 ("pmdomain: core: Add GENPD_FLAG_DEV_NAME_FW flag")
> Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>

Please tell me which author domain it is supposed to be. redhat.com or
v3.sk?
diff mbox series

Patch

diff --git a/drivers/clk/mmp/pwr-island.c b/drivers/clk/mmp/pwr-island.c
index edaa2433a472..eaf5d2c5e593 100644
--- a/drivers/clk/mmp/pwr-island.c
+++ b/drivers/clk/mmp/pwr-island.c
@@ -106,10 +106,10 @@  struct generic_pm_domain *mmp_pm_domain_register(const char *name,
 	pm_domain->flags = flags;
 	pm_domain->lock = lock;
 
-	pm_genpd_init(&pm_domain->genpd, NULL, true);
 	pm_domain->genpd.name = name;
 	pm_domain->genpd.power_on = mmp_pm_domain_power_on;
 	pm_domain->genpd.power_off = mmp_pm_domain_power_off;
+	pm_genpd_init(&pm_domain->genpd, NULL, true);
 
 	return &pm_domain->genpd;
 }