* [PATCH] pmdomain: imx: Propagate SCU provider registration failures
@ 2026-09-06 3:38 Pengpeng Hou
2026-09-21 14:33 ` Ulf Hansson
0 siblings, 1 reply; 2+ messages in thread
From: Pengpeng Hou @ 2026-09-06 3:38 UTC (permalink / raw)
To: Ulf Hansson
Cc: Pengpeng Hou, Frank Li, Sascha Hauer, Pengutronix Kernel Team,
Fabio Estevam, Shawn Guo, A.s. Dong, linux-pm, imx,
linux-arm-kernel, linux-kernel
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@163.com>
---
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)
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] pmdomain: imx: Propagate SCU provider registration failures
2026-09-06 3:38 [PATCH] pmdomain: imx: Propagate SCU provider registration failures Pengpeng Hou
@ 2026-09-21 14:33 ` Ulf Hansson
0 siblings, 0 replies; 2+ messages in thread
From: Ulf Hansson @ 2026-09-21 14:33 UTC (permalink / raw)
To: Pengpeng Hou
Cc: Ulf Hansson, Frank Li, Sascha Hauer, Pengutronix Kernel Team,
Fabio Estevam, Shawn Guo, A.s. Dong, linux-pm, imx,
linux-arm-kernel, linux-kernel
On Sun, Sep 6, 2026 at 5:38 AM Pengpeng Hou <hppiscas@163.com> wrote:
>
> 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@163.com>
Applied for next, thanks!
Kind regards
Uffe
> ---
> 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)
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-09-21 14:33 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-06 3:38 [PATCH] pmdomain: imx: Propagate SCU provider registration failures Pengpeng Hou
2026-09-21 14:33 ` Ulf Hansson
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®