[PATCH] pmdomain: imx: Propagate SCU provider registration failures

From: Pengpeng Hou

Date: Sat Sep 05 2026 - 23:39:56 EST


imx_scu_init_pm_domains() ignores of_genpd_add_provider_onecell() and
returns success even when none of the initialized domains are published to
DT consumers.

Return the provider error and remove the initialized domains in reverse
order before devm releases their backing storage on probe failure.

The issue was found by our static-analysis tool and manually reviewed.

Fixes: c800cd7824bd ("firmware: imx: add SCU power domain driver")
Assisted-by: gpt 5
Signed-off-by: Pengpeng Hou <hppiscas@xxxxxxx>
---
drivers/pmdomain/imx/scu-pd.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/drivers/pmdomain/imx/scu-pd.c b/drivers/pmdomain/imx/scu-pd.c
index e3f9e741daf7..05d4364f34be 100644
--- a/drivers/pmdomain/imx/scu-pd.c
+++ b/drivers/pmdomain/imx/scu-pd.c
@@ -474,7 +474,7 @@ static int imx_scu_init_pm_domains(struct device *dev,
struct genpd_onecell_data *pd_data;
struct imx_sc_pm_domain *sc_pd;
u32 count = 0;
- int i, j;
+ int i, j, ret;

for (i = 0; i < pd_soc->num_ranges; i++)
count += pd_ranges[i].num;
@@ -503,7 +503,13 @@ static int imx_scu_init_pm_domains(struct device *dev,
pd_data->num_domains = count;
pd_data->xlate = imx_scu_pd_xlate;

- of_genpd_add_provider_onecell(dev->of_node, pd_data);
+ ret = of_genpd_add_provider_onecell(dev->of_node, pd_data);
+ if (ret) {
+ while (count)
+ pm_genpd_remove(domains[--count]);
+
+ return ret;
+ }

return 0;
}
--
2.50.1 (Apple Git-155)