diff mbox series

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

Message ID 20190804163445.6862-1-nishkadg.linux@gmail.com (mailing list archive)
State Mainlined
Commit 5911dba556cf41a14907ed04b5636cf852b17933
Headers show
Series clk: versatile: Add of_node_put() in cm_osc_setup() | expand

Commit Message

Nishka Dasgupta Aug. 4, 2019, 4:34 p.m. UTC
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.

Signed-off-by: Nishka Dasgupta <nishkadg.linux@gmail.com>
---
 drivers/clk/versatile/clk-versatile.c | 1 +
 1 file changed, 1 insertion(+)

Comments

Linus Walleij Aug. 6, 2019, 12:53 p.m. UTC | #1
On Sun, Aug 4, 2019 at 6:34 PM Nishka Dasgupta <nishkadg.linux@gmail.com> wrote:

> 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.
>
> Signed-off-by: Nishka Dasgupta <nishkadg.linux@gmail.com>

Reviewed-by: Linus Walleij <linus.walleij@linaro.org>

Yours,
Linus Walleij
Stephen Boyd Aug. 7, 2019, 10:25 p.m. UTC | #2
Quoting Nishka Dasgupta (2019-08-04 09:34:44)
> 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.
> 
> Signed-off-by: Nishka Dasgupta <nishkadg.linux@gmail.com>
> ---

Applied to clk-next
diff mbox series

Patch

diff --git a/drivers/clk/versatile/clk-versatile.c b/drivers/clk/versatile/clk-versatile.c
index 90bb0b041b7a..fd54d5c0251c 100644
--- a/drivers/clk/versatile/clk-versatile.c
+++ b/drivers/clk/versatile/clk-versatile.c
@@ -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;