Skip to contentSkip to conversation

ARM: highbank: Fix OF node refcount leaks

PATCH In review Yuho Choi 1 participant 2 messages May 25 – Jun 19

Subsystems (3)
lore
Share & tools
lore

Yuho Choi

author
#0 lore raw

PATCH 1/1 ARM: highbank: Fix OF node refcount leaks

highbank_init_irq() checks for a Cortex-A9 node with of_find_compatible_node(), but uses the returned node only as a boolean and drops the pointer without releasing the reference.

highbank_init() has the same issue for the Calxeda system registers node after mapping it with of_iomap(). of_iomap() does not consume the device node reference.

Release both node references after the corresponding use.

Fixes 7a2848d369b2 ("ARM: highbank: abstract out SCU usage")
Fixes 26cae166cff9 ("ARM: highbank: remove custom .init_time hook")
---
 arch/arm/mach-highbank/highbank.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
arch/arm/mach-highbank/highbank.c +7 -1
index 47335c7dadf8..430f1ca125d3 100644
@@ -50,10 +50,15 @@ static void highbank_l2c310_write_sec(unsigned long val, unsigned reg)
 
 static void __init highbank_init_irq(void)
 {
+	struct device_node *np;
+
 	irqchip_init();
 
-	if (of_find_compatible_node(NULL, NULL, "arm,cortex-a9"))
+	np = of_find_compatible_node(NULL, NULL, "arm,cortex-a9");
+	if (np) {
+		of_node_put(np);
 		highbank_scu_map_io();
+	}
 }
 
 static void highbank_power_off(void)
@@ -141,6 +146,7 @@ static void __init highbank_init(void)
 	/* Map system registers */
 	np = of_find_compatible_node(NULL, NULL, "calxeda,hb-sregs");
 	sregs_base = of_iomap(np, 0);
+	of_node_put(np);
 	WARN_ON(!sregs_base);
 
 	register_platform_power_off(highbank_power_off);
Signature · 1 line
2.43.0
author
#1 lore raw

Hi,

Just a gentle ping on this patch.

I would appreciate any feedback when you have a chance to review this.

Thanks