Skip to contentSkip to conversation

clk: ti: dm814x: Add of_node_put() to prevent memory leak

PATCH Applied Nishka Dasgupta 2 participants 2 messages Aug 4, 2019 – Aug 7, 2019

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

PATCH 1/1 clk: ti: dm814x: Add of_node_put() to prevent memory leak

In function dm814x_adpll_early_init, variable np takes the value returned by of_find_node_by_name, which gets a node but does not put it. If np is not put before return, it may cause a memory leak. Hence put np before return.
Issue found with Coccinelle.

---
 drivers/clk/ti/clk-814x.c | 1 +
 1 file changed, 1 insertion(+)
drivers/clk/ti/clk-814x.c +1 -0
index e8cee6f3b4a0..087cfa75ac24 100644
@@ -66,6 +66,7 @@ static int __init dm814x_adpll_early_init(void)
 	}
 
 	of_platform_populate(np, NULL, NULL, NULL);
+	of_node_put(np);
 
 	return 0;
 }
Signature · 1 line
2.19.1
maintainer Applied
#1 lore raw

Quoting Nishka Dasgupta (2019-08-04 09:33:28)

Quoted 8 lines

In function dm814x_adpll_early_init, variable np takes the value returned by of_find_node_by_name, which gets a node but does not put it. If np is not put before return, it may cause a memory leak. Hence put np before return.
Issue found with Coccinelle.

---

Applied to clk-next