2022-06-17 12:55:28

by Liang He

[permalink] [raw]
Subject: [PATCH] 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.

Signed-off-by: Liang He <[email protected]>
---
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 9e4cb2ffd580..c561b3b7a9ee 100644
--- a/arch/arm/mach-socfpga/socfpga.c
+++ b/arch/arm/mach-socfpga/socfpga.c
@@ -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)
--
2.25.1


2022-06-22 09:05:47

by Krzysztof Kozlowski

[permalink] [raw]
Subject: Re: [PATCH] arm: mach-socfpga: Fix refcount leak bug in socfpga

On 17/06/2022 14:06, Liang He wrote:
> 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.
>
> Signed-off-by: Liang He <[email protected]>
> ---

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