Skip to contentSkip to conversation

xtensa: kernel: Fix refcount leak bug in time.c

PATCH In review Liang He 2 participants 2 messages Jun 17, 2022 – Jun 18, 2022 Tensilica Xtensa port (xtensa)

lore
Share & tools
lore

Liang He

author
#0 lore raw

PATCH 1/1 xtensa: kernel: Fix refcount leak bug in time.c

In calibrate_ccount(), 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/xtensa/kernel/time.c | 1 +
 1 file changed, 1 insertion(+)
arch/xtensa/kernel/time.c +1 -0
index e8ceb1528608..16b8a6273772 100644
@@ -154,6 +154,7 @@ static void __init calibrate_ccount(void)
 	cpu = of_find_compatible_node(NULL, NULL, "cdns,xtensa-cpu");
 	if (cpu) {
 		clk = of_clk_get(cpu, 0);
+		of_node_put(cpu);
 		if (!IS_ERR(clk)) {
 			ccount_freq = clk_get_rate(clk);
 			return;
Signature · 1 line
2.25.1
maintainer
#1 lore raw
Quoted 9 lines · Liang He

In calibrate_ccount(), 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/xtensa/kernel/time.c | 1 +
 1 file changed, 1 insertion(+)

Thanks. Applied to my xtensa tree.

-- Max