mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] soc: dove: fix OF node leak in dove_init_pmu()
@ 2026-11-27  7:42 zhaofeng2
  2026-11-27 14:46 ` Andrew Lunn
  2026-11-30  3:38 ` [PATCH v2] soc: dove: fix OF node leaks " zhaofeng2
  0 siblings, 2 replies; 4+ messages in thread
From: zhaofeng2 @ 2026-11-27  7:42 UTC (permalink / raw)
  To: Andrew Lunn; +Cc: Zhao Feng, linux-arm-kernel, linux-kernel

From: Zhao Feng <zhaofeng2@cmss.chinamobile.com>

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@cmss.chinamobile.com>
---
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;
+}



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-11-30 13:01 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-27  7:42 [PATCH] soc: dove: fix OF node leak in dove_init_pmu() zhaofeng2
2026-11-27 14:46 ` Andrew Lunn
2026-11-30  3:38 ` [PATCH v2] soc: dove: fix OF node leaks " zhaofeng2
2026-11-30 13:01   ` Andrew Lunn

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®