* [PATCH] pmdomain: arm: scmi: Check pm_genpd_init() in probe
@ 2026-07-05 10:32 Guangshuo Li
2026-07-06 9:34 ` Sudeep Holla
0 siblings, 1 reply; 2+ messages in thread
From: Guangshuo Li @ 2026-07-05 10:32 UTC (permalink / raw)
To: Sudeep Holla, Cristian Marussi, Ulf Hansson, Peng Fan, arm-scmi,
linux-arm-kernel, linux-pm, linux-kernel
Cc: Guangshuo Li
scmi_pm_domain_probe() stores each domain in the onecell domains array
after calling pm_genpd_init(), but it ignores the return value from
pm_genpd_init().
If pm_genpd_init() fails, the genpd has not been added to the global
genpd list. The probe code nevertheless stores the genpd pointer in the
domains array. A later provider registration failure then unwinds the
array with pm_genpd_remove(), which can try to remove a genpd that was
never registered.
Check the return value from pm_genpd_init() and only store successfully
initialized domains in the onecell array. On failure, unwind the domains
that were already initialized.
Fixes: 7458f72cc28f ("pmdomain: arm: scmi: Fix genpd leak on provider registration failure")
Signed-off-by: Guangshuo Li <lgs201920130244@gmail.com>
---
drivers/pmdomain/arm/scmi_pm_domain.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/drivers/pmdomain/arm/scmi_pm_domain.c b/drivers/pmdomain/arm/scmi_pm_domain.c
index 3d73aef21d2f..a60189ea32a8 100644
--- a/drivers/pmdomain/arm/scmi_pm_domain.c
+++ b/drivers/pmdomain/arm/scmi_pm_domain.c
@@ -99,8 +99,12 @@ static int scmi_pm_domain_probe(struct scmi_device *sdev)
scmi_pd->genpd.power_on = scmi_pd_power_on;
scmi_pd->genpd.flags = GENPD_FLAG_ACTIVE_WAKEUP;
- pm_genpd_init(&scmi_pd->genpd, NULL,
- state == SCMI_POWER_STATE_GENERIC_OFF);
+ ret = pm_genpd_init(&scmi_pd->genpd, NULL,
+ state == SCMI_POWER_STATE_GENERIC_OFF);
+ if (ret) {
+ dev_err_probe(dev, ret, "failed to init domain %d\n", i);
+ goto err_rm_genpds;
+ }
domains[i] = &scmi_pd->genpd;
}
--
2.43.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] pmdomain: arm: scmi: Check pm_genpd_init() in probe
2026-07-05 10:32 [PATCH] pmdomain: arm: scmi: Check pm_genpd_init() in probe Guangshuo Li
@ 2026-07-06 9:34 ` Sudeep Holla
0 siblings, 0 replies; 2+ messages in thread
From: Sudeep Holla @ 2026-07-06 9:34 UTC (permalink / raw)
To: Guangshuo Li
Cc: Cristian Marussi, Sudeep Holla, Ulf Hansson, Peng Fan, arm-scmi,
linux-arm-kernel, linux-pm, linux-kernel
On Sun, Jul 05, 2026 at 06:32:56PM +0800, Guangshuo Li wrote:
> scmi_pm_domain_probe() stores each domain in the onecell domains array
> after calling pm_genpd_init(), but it ignores the return value from
> pm_genpd_init().
>
> If pm_genpd_init() fails, the genpd has not been added to the global
> genpd list. The probe code nevertheless stores the genpd pointer in the
> domains array. A later provider registration failure then unwinds the
> array with pm_genpd_remove(), which can try to remove a genpd that was
> never registered.
>
> Check the return value from pm_genpd_init() and only store successfully
> initialized domains in the onecell array. On failure, unwind the domains
> that were already initialized.
>
It was done that way intentionally IIRC. We don't want to remove all the
power domains if some not so important power domains fail to initialise.
You can log the error if that helps but removing all the domains that
have initialised seems bit of extreme.
Are you facing any issues on a real platform or is this just by code
inspection.
--
Regards,
Sudeep
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-07-06 9:34 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-05 10:32 [PATCH] pmdomain: arm: scmi: Check pm_genpd_init() in probe Guangshuo Li
2026-07-06 9:34 ` Sudeep Holla
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox