Skip to contentSkip to conversation

clk: st: clk-flexgen: Add of_node_put() in st_of_flexgen_setup()

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

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 clk: st: clk-flexgen: Add of_node_put() in st_of_flexgen_setup()

In function st_of_flexgen_setup, variable pnode takes the return value of of_get_parent, which gets a node but does not put it. If pnode is not put before the function returns, it may cause a memory leak. Hence put pnode after its last occurrence.
Issue found with Coccinelle.

---
 drivers/clk/st/clk-flexgen.c | 1 +
 1 file changed, 1 insertion(+)
drivers/clk/st/clk-flexgen.c +1 -0
index d18e49b4976f..4413b6e04a8e 100644
@@ -326,6 +326,7 @@ static void __init st_of_flexgen_setup(struct device_node *np)
 		return;
 
 	reg = of_iomap(pnode, 0);
+	of_node_put(pnode);
 	if (!reg)
 		return;
 
Signature · 1 line
2.19.1
maintainer Applied
#1 lore raw

Quoting Nishka Dasgupta (2019-08-04 09:31:51)

Quoted 8 lines

In function st_of_flexgen_setup, variable pnode takes the return value of of_get_parent, which gets a node but does not put it. If pnode is not put before the function returns, it may cause a memory leak. Hence put pnode after its last occurrence.
Issue found with Coccinelle.

---

Applied to clk-next