[PATCH v1] ARM: socfpga: Fix OF node refcount leaks in sysmgr init

Yuho Choi posted 1 patch 20 hours ago
arch/arm/mach-socfpga/socfpga.c | 3 +++
1 file changed, 3 insertions(+)
[PATCH v1] ARM: socfpga: Fix OF node refcount leaks in sysmgr init
Posted by Yuho Choi 20 hours ago
socfpga_sysmgr_init() looks up the sys manager, reset manager, and
SDR controller nodes with of_find_compatible_node(). The returned node
references are used to read properties and map registers, but none of
them are released before np is reused or the function returns.

Drop each reference after the corresponding mapping attempt. The MMIO
mappings do not depend on keeping the device node references held.

Fixes: 9c4566a117a6 ("ARM: socfpga: Enable SMP for socfpga")
Fixes: 44fd8c7d4005 ("ARM: socfpga: support suspend to ram")
Signed-off-by: Yuho Choi <oss.patchbox@gmail.com>
---
 arch/arm/mach-socfpga/socfpga.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/arch/arm/mach-socfpga/socfpga.c b/arch/arm/mach-socfpga/socfpga.c
index 4332af2d8b862..663765280d0c9 100644
--- a/arch/arm/mach-socfpga/socfpga.c
+++ b/arch/arm/mach-socfpga/socfpga.c
@@ -34,12 +34,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)

base-commit: f0100363d8c374bd8e9ea7c9ba02744f0b802ca4
-- 
2.43.0