Skip to contentSkip to conversation

pmdomain: ti: fix device node leak in probe

PATCH New Aryan Sinha 1 participant 1 message Oct 1

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 pmdomain: ti: fix device node leak in probe

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")
---
 drivers/pmdomain/ti/ti_sci_pm_domains.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/pmdomain/ti/ti_sci_pm_domains.c +6 -2
index 949e4115f..9cb6133fd 100644
@@ -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;
Signature · 1 line
2.46.0