Skip to contentSkip to conversation

ARM: cns3xxx: Fix refcount leak in cns3xxx_init

PATCH In review Miaoqian Lin 3 participants 3 messages Jun 5, 2022 – Jun 24, 2022

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ARM: cns3xxx: Fix refcount leak in cns3xxx_init

of_find_compatible_node() returns a node pointer with refcount incremented, we should use of_node_put() on it when done. Add missing of_node_put() to avoid refcount leak.

Fixes 415f59142d9d ("ARM: cns3xxx: initial DT support")
---
 arch/arm/mach-cns3xxx/core.c | 2 ++
 1 file changed, 2 insertions(+)
arch/arm/mach-cns3xxx/core.c +2 -0
index e4f4b20b83a2..3fc4ec830e3a 100644
@@ -372,6 +372,7 @@ static void __init cns3xxx_init(void)
 		/* De-Asscer SATA Reset */
 		cns3xxx_pwr_soft_rst(CNS3XXX_PWR_SOFTWARE_RST(SATA));
 	}
+	of_node_put(dn);
 
 	dn = of_find_compatible_node(NULL, NULL, "cavium,cns3420-sdhci");
 	if (of_device_is_available(dn)) {
@@ -385,6 +386,7 @@ static void __init cns3xxx_init(void)
 		cns3xxx_pwr_clk_en(CNS3XXX_PWR_CLK_EN(SDIO));
 		cns3xxx_pwr_soft_rst(CNS3XXX_PWR_SOFTWARE_RST(SDIO));
 	}
+	of_node_put(dn);
 
 	pm_power_off = cns3xxx_power_off;
 
Signature · 1 line
2.25.1
Acked-by on v1 1/1
#1 lore raw
Quoted 6 lines · Miaoqian Lin

of_find_compatible_node() returns a node pointer with refcount incremented, we should use of_node_put() on it when done. Add missing of_node_put() to avoid refcount leak.

Fixes 415f59142d9d ("ARM: cns3xxx: initial DT support")

Arnd, I guess you are in the best position to pick this patch up? Thanks to both of you.

Quoted 23 lines
---
 arch/arm/mach-cns3xxx/core.c | 2 ++
 1 file changed, 2 insertions(+)
arch/arm/mach-cns3xxx/core.c +2 -0
index e4f4b20b83a2..3fc4ec830e3a 100644
@@ -372,6 +372,7 @@ static void __init cns3xxx_init(void)
 		/* De-Asscer SATA Reset */
 		cns3xxx_pwr_soft_rst(CNS3XXX_PWR_SOFTWARE_RST(SATA));
 	}
+	of_node_put(dn);
 
 	dn = of_find_compatible_node(NULL, NULL, "cavium,cns3420-sdhci");
 	if (of_device_is_available(dn)) {
@@ -385,6 +386,7 @@ static void __init cns3xxx_init(void)
 		cns3xxx_pwr_clk_en(CNS3XXX_PWR_CLK_EN(SDIO));
 		cns3xxx_pwr_soft_rst(CNS3XXX_PWR_SOFTWARE_RST(SDIO));
 	}
+	of_node_put(dn);
 
 	pm_power_off = cns3xxx_power_off;
Signature · 5 lines
Krzysztof "Chris" Hałasa

Sieć Badawcza Łukasiewicz
Przemysłowy Instytut Automatyki i Pomiarów PIAP
Al. Jerozolimskie 202, 02-486 Warszawa
#2 lore raw
Quoted 7 lines · Krzysztof Hałasa
Quoted 4 lines · Miaoqian Lin

of_find_compatible_node() returns a node pointer with refcount incremented, we should use of_node_put() on it when done. Add missing of_node_put() to avoid refcount leak.

Quoted 7 lines
Quoted 2 lines
Fixes 415f59142d9d ("ARM: cns3xxx: initial DT support")

Arnd, I guess you are in the best position to pick this patch up? Thanks to both of you.

Done now, thanks!

Arnd