[PATCH] soc: dove: fix OF node leak in dove_init_pmu()

From: zhaofeng2

Date: Fri Nov 27 2026 - 02:42:27 EST


From: Zhao Feng <zhaofeng2@xxxxxxxxxxxxxxxxxxxx>

dove_init_pmu() calls of_get_child_by_name() to obtain the
"domains" child node of the PMU node, but the reference is
leaked on the two early failure paths and on the successful
return.

Drop the reference with of_node_put() once the node is no
longer needed.

Signed-off-by: Zhao Feng <zhaofeng2@xxxxxxxxxxxxxxxxxxxx>
---
Verified against current tree. Leak found by code inspection
(OF reference-counting audit of dove_init_pmu()).

soc/dove/pmu.c | 11 +--------++---
1 file changed, 8 insertions(+), 3 deletions(-)

--- a/drivers/soc/dove/pmu.c
+++ b/drivers/soc/dove/pmu.c
@@ -388,8 +388,10 @@
}

pmu = kzalloc(sizeof(*pmu), GFP_KERNEL);
- if (!pmu)
+ if (!pmu) {
+ of_node_put(domains_node);
return -ENOMEM;
+ }

spin_lock_init(&pmu->lock);
pmu->of_node = np_pmu;
@@ -400,6 +402,7 @@
iounmap(pmu->pmu_base);
iounmap(pmu->pmc_base);
kfree(pmu);
+ of_node_put(domains_node);
return -ENOMEM;
}

@@ -451,5 +454,7 @@
pr_err("dove_init_pmu_irq() failed: %d\n", ret);
}

- return 0;
-}
+ of_node_put(domains_node);
+
+ return 0;
+}