[PATCH] pmdomain: arm: scmi: Check pm_genpd_init() in probe
Guangshuo Li
lgs201920130244 at gmail.com
Sun Jul 5 03:32:56 PDT 2026
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 at 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
More information about the linux-arm-kernel
mailing list