Skip to contentSkip to conversation

clk: versatile: Add of_node_put() in cm_osc_setup()

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

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

PATCH 1/1 clk: versatile: Add of_node_put() in cm_osc_setup()

In function cm_osc_setup, variable parent takes the value returned by of_get_parent, which gets a node but does not put it. If parent is not put before it goes out of scope, it may cause a memory leak. Hence put parent before the function terminates.
Issue found with Coccinelle.

---
 drivers/clk/versatile/clk-versatile.c | 1 +
 1 file changed, 1 insertion(+)
drivers/clk/versatile/clk-versatile.c +1 -0
index 90bb0b041b7a..fd54d5c0251c 100644
@@ -70,6 +70,7 @@ static void __init cm_osc_setup(struct device_node *np,
 			return;
 		}
 		cm_base = of_iomap(parent, 0);
+		of_node_put(parent);
 		if (!cm_base) {
 			pr_err("could not remap core module base\n");
 			return;
Signature · 1 line
2.19.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 7 lines · Nishka Dasgupta

In function cm_osc_setup, variable parent takes the value returned by of_get_parent, which gets a node but does not put it. If parent is not put before it goes out of scope, it may cause a memory leak. Hence put parent before the function terminates.
Issue found with Coccinelle.

Yours,
Linus Walleij

maintainer Applied
#2 lore raw
In reply to Nishka Dasgupta

Quoting Nishka Dasgupta (2019-08-04 09:34:44)

Quoted 8 lines

In function cm_osc_setup, variable parent takes the value returned by of_get_parent, which gets a node but does not put it. If parent is not put before it goes out of scope, it may cause a memory leak. Hence put parent before the function terminates.
Issue found with Coccinelle.

---

Applied to clk-next