Skip to contentSkip to conversation

arm: mach-socfpga: Fix refcount leak bug in socfpga

PATCH In review Liang He 2 participants 2 messages Jun 17, 2022 – Jun 22, 2022

Subsystems (3)
lore
Share & tools
lore

Liang He

author
#0 lore raw

PATCH 1/1 arm: mach-socfpga: Fix refcount leak bug in socfpga

In socfpga_sysmgr_init(), of_find_compatible_node() will return a node pointer with refcount incremented. We should use of_node_put() when it is not used anymore.

---
 arch/arm/mach-socfpga/socfpga.c | 3 +++
 1 file changed, 3 insertions(+)
arch/arm/mach-socfpga/socfpga.c +3 -0
index 9e4cb2ffd580..c561b3b7a9ee 100644
@@ -36,12 +36,15 @@ static void __init socfpga_sysmgr_init(void)
 	sync_cache_w(&socfpga_cpu1start_addr);
 
 	sys_manager_base_addr = of_iomap(np, 0);
+	of_node_put(np);
 
 	np = of_find_compatible_node(NULL, NULL, "altr,rst-mgr");
 	rst_manager_base_addr = of_iomap(np, 0);
+	of_node_put(np);
 
 	np = of_find_compatible_node(NULL, NULL, "altr,sdr-ctl");
 	sdr_ctl_base_addr = of_iomap(np, 0);
+	of_node_put(np);
 }
 
 static void __init socfpga_init_irq(void)
Signature · 7 lines
2.25.1


_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
#1 lore raw
Quoted 6 lines · Liang He

In socfpga_sysmgr_init(), of_find_compatible_node() will return a node pointer with refcount incremented. We should use of_node_put() when it is not used anymore.

---

Before applying the patch please check it carefully. Previous evidence [1][2] suggests that not it was not even compiled.

[1] https://lore.kernel.org/all/[email protected]/

[2]
https://lore.kernel.org/all/[email protected]/

Best regards,
Krzysztof