[PATCH] pmdomain: ti: fix device node leak in probe

From: Aryan Sinha

Date: Thu Oct 01 2026 - 12:40:07 EST


for_each_node_with_property() takes a reference on np each iteration
and drops it on the next one. The two allocation failure paths return
from inside the loop, so np is leaked.

Put np before returning fixes it.

Fixes: efa5c01cd7ee ("soc: ti: ti_sci_pm_domains: switch to use multiple genpds instead of one")
Signed-off-by: Aryan Sinha <sinha.aryan03@xxxxxxxxx>
---
drivers/pmdomain/ti/ti_sci_pm_domains.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/pmdomain/ti/ti_sci_pm_domains.c b/drivers/pmdomain/ti/ti_sci_pm_domains.c
index 949e4115f..9cb6133fd 100644
--- a/drivers/pmdomain/ti/ti_sci_pm_domains.c
+++ b/drivers/pmdomain/ti/ti_sci_pm_domains.c
@@ -262,14 +262,18 @@ static int ti_sci_pm_domain_probe(struct platform_device *pdev)
}

pd = devm_kzalloc(dev, sizeof(*pd), GFP_KERNEL);
- if (!pd)
+ if (!pd) {
+ of_node_put(np);
return -ENOMEM;
+ }

pd->pd.name = devm_kasprintf(dev, GFP_KERNEL,
"pd:%d",
args.args[0]);
- if (!pd->pd.name)
+ if (!pd->pd.name) {
+ of_node_put(np);
return -ENOMEM;
+ }

pd->pd.power_off = ti_sci_pd_power_off;
pd->pd.power_on = ti_sci_pd_power_on;
--
2.46.0