Skip to contentSkip to conversation

ARM: mvebu: Fix CPU node reference leak in get_cpu_clk()

PATCH New Yuho Choi 1 participant 1 message Jun 15

Subsystems (3)
lore
Share & tools
lore

Yuho Choi

author
#0 lore raw

PATCH 1/1 ARM: mvebu: Fix CPU node reference leak in get_cpu_clk()

of_get_cpu_node() returns a reference to the CPU device node. get_cpu_clk() only needs that node for of_clk_get(), but never drops the reference after the clock lookup.

Drop the CPU node reference before returning the clock, covering both the successful lookup and the IS_ERR() path.

Fixes f6cec7cd0777 ("ARM: mvebu: remove device tree parsing for cpu nodes")
---
 arch/arm/mach-mvebu/platsmp.c | 1 +
 1 file changed, 1 insertion(+)
arch/arm/mach-mvebu/platsmp.c +1 -0
index 18384ea6862c..0f14d7376770 100644
@@ -42,6 +42,7 @@ static struct clk *get_cpu_clk(int cpu)
 	if (WARN(!np, "missing cpu node\n"))
 		return NULL;
 	cpu_clk = of_clk_get(np, 0);
+	of_node_put(np);
 	if (WARN_ON(IS_ERR(cpu_clk)))
 		return NULL;
 	return cpu_clk;
Signature · 1 line
2.43.0