Skip to contentSkip to conversation

arm: mach-omap2: omap4-common: Fix refcount leak bug

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

Subsystems (3)
lore
Share & tools
lore

Liang He

author
#0 lore raw

PATCH 1/1 arm: mach-omap2: omap4-common: Fix refcount leak bug

In omap4_sram_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-omap2/omap4-common.c | 1 +
 1 file changed, 1 insertion(+)
arch/arm/mach-omap2/omap4-common.c +1 -0
index 6d1eb4eefefe..e981bf57e64f 100644
@@ -135,6 +135,7 @@ static int __init omap4_sram_init(void)
 		pr_warn("%s:Unable to allocate sram needed to handle errata I688\n",
 			__func__);
 	sram_pool = of_gen_pool_get(np, "sram", 0);
+	of_node_put(np);
 	if (!sram_pool)
 		pr_warn("%s:Unable to get sram pool needed to handle errata I688\n",
 			__func__);
Signature · 1 line
2.25.1
maintainer
#1 lore raw
Quoted 14 lines · Liang He

In omap4_sram_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-omap2/omap4-common.c | 1 +
 1 file changed, 1 insertion(+)
arch/arm/mach-omap2/omap4-common.c +0 -0
index 6d1eb4eefefe..e981bf57e64f 100644

arch/arm/mach-omap2/omap4-common.c static int __init omap4_sram_init(void) · line 141

Quoted 7 lines
arch/arm/mach-omap2/omap4-common.c +1 -0
@@ -135,6 +135,7 @@ static int __init omap4_sram_init(void)
 		pr_warn("%s:Unable to allocate sram needed to handle errata I688\n",
 			__func__);
 	sram_pool = of_gen_pool_get(np, "sram", 0);
+	of_node_put(np);
 	if (!sram_pool)
 		pr_warn("%s:Unable to get sram pool needed to handle errata I688\n",
 			__func__);

Here too sram_pool is used aftger of_node_put().

Regards,

Tony

author
#2 lore raw
Quoted 25 lines · Tony Lindgren
Quoted 14 lines · Liang He

In omap4_sram_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-omap2/omap4-common.c | 1 +
 1 file changed, 1 insertion(+)
arch/arm/mach-omap2/omap4-common.c +0 -0
index 6d1eb4eefefe..e981bf57e64f 100644

arch/arm/mach-omap2/omap4-common.c static int __init omap4_sram_init(void) · line 141

Quoted 7 lines
arch/arm/mach-omap2/omap4-common.c +1 -0
@@ -135,6 +135,7 @@ static int __init omap4_sram_init(void)
 		pr_warn("%s:Unable to allocate sram needed to handle errata I688\n",
 			__func__);
 	sram_pool = of_gen_pool_get(np, "sram", 0);
+	of_node_put(np);
 	if (!sram_pool)
 		pr_warn("%s:Unable to get sram pool needed to handle errata I688\n",
 			__func__);

Here too sram_pool is used aftger of_node_put().

Quoted 3 lines

Regards,

Tony

Thanks, Tony.

I will send a new patch to fix the order problem.

Liang