[PATCH] xtfpga: Fix refcount leak bug in setup

Liang He posted 1 patch 3 years, 10 months ago
arch/xtensa/platforms/xtfpga/setup.c | 1 +
1 file changed, 1 insertion(+)
[PATCH] xtfpga: Fix refcount leak bug in setup
Posted by Liang He 3 years, 10 months ago
In machine_setup(), 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 <windhl@126.com>
---
 arch/xtensa/platforms/xtfpga/setup.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/xtensa/platforms/xtfpga/setup.c b/arch/xtensa/platforms/xtfpga/setup.c
index 538e6748e85a..c79c1d09ea86 100644
--- a/arch/xtensa/platforms/xtfpga/setup.c
+++ b/arch/xtensa/platforms/xtfpga/setup.c
@@ -133,6 +133,7 @@ static int __init machine_setup(void)
 
 	if ((eth = of_find_compatible_node(eth, NULL, "opencores,ethoc")))
 		update_local_mac(eth);
+	of_node_put(eth);
 	return 0;
 }
 arch_initcall(machine_setup);
-- 
2.25.1
Re: [PATCH] xtfpga: Fix refcount leak bug in setup
Posted by Max Filippov 3 years, 10 months ago
On Fri, Jun 17, 2022 at 4:54 AM Liang He <windhl@126.com> wrote:
>
> In machine_setup(), 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 <windhl@126.com>
> ---
>  arch/xtensa/platforms/xtfpga/setup.c | 1 +
>  1 file changed, 1 insertion(+)

Thanks. Applied to my xtensa tree.

-- Max