[PATCH] soc: qcom: rpmh-rsc: unwind notifiers on populate failure

From: Pengpeng Hou

Date: Mon Jun 15 2026 - 20:59:26 EST


rpmh_rsc_probe() registers either a genpd notifier or a CPU PM notifier
before populating child devices. The genpd path is unwound if child
population fails, but the CPU PM notifier registration return value is
ignored and the notifier remains registered on the same failure path.

Check the CPU PM notifier registration result and unregister it if child
population fails. Also depopulate any children that were created before
devm_of_platform_populate() returned an error, because the devres cleanup
action is only installed after successful population.

Signed-off-by: Pengpeng Hou <pengpeng@xxxxxxxxxxx>
---
drivers/soc/qcom/rpmh-rsc.c | 17 +++++++++++++----
1 file changed, 13 insertions(+), 4 deletions(-)

diff --git a/drivers/soc/qcom/rpmh-rsc.c b/drivers/soc/qcom/rpmh-rsc.c
index c6f7d5c9c493..a75ff97423e8 100644
--- a/drivers/soc/qcom/rpmh-rsc.c
+++ b/drivers/soc/qcom/rpmh-rsc.c
@@ -1033,6 +1033,7 @@ static int rpmh_rsc_probe(struct platform_device *pdev)
struct device_node *dn = pdev->dev.of_node;
struct rsc_drv *drv;
char drv_id[10] = {0};
+ bool cpu_pm_registered = false;
int ret, irq;
u32 solver_config;
u32 rsc_id;
@@ -1107,7 +1108,10 @@ static int rpmh_rsc_probe(struct platform_device *pdev)
return ret;
} else {
drv->rsc_pm.notifier_call = rpmh_rsc_cpu_pm_callback;
- cpu_pm_register_notifier(&drv->rsc_pm);
+ ret = cpu_pm_register_notifier(&drv->rsc_pm);
+ if (ret)
+ return ret;
+ cpu_pm_registered = true;
}
}

@@ -1123,9 +1127,14 @@ static int rpmh_rsc_probe(struct platform_device *pdev)
drv->dev = &pdev->dev;

ret = devm_of_platform_populate(&pdev->dev);
- if (ret && pdev->dev.pm_domain) {
- dev_pm_genpd_remove_notifier(&pdev->dev);
- pm_runtime_disable(&pdev->dev);
+ if (ret) {
+ of_platform_depopulate(&pdev->dev);
+ if (pdev->dev.pm_domain) {
+ dev_pm_genpd_remove_notifier(&pdev->dev);
+ pm_runtime_disable(&pdev->dev);
+ } else if (cpu_pm_registered) {
+ cpu_pm_unregister_notifier(&drv->rsc_pm);
+ }
}

return ret;
--
2.50.1 (Apple Git-155)