clk: st: clk-flexgen: Add of_node_put() in st_of_flexgen_setup()
authorNishka Dasgupta <nishkadg.linux@gmail.com>
Sun, 4 Aug 2019 16:31:51 +0000 (22:01 +0530)
committerStephen Boyd <sboyd@kernel.org>
Wed, 7 Aug 2019 22:26:32 +0000 (15:26 -0700)
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.

Signed-off-by: Nishka Dasgupta <nishkadg.linux@gmail.com>
Link: https://lkml.kernel.org/r/20190804163151.6511-1-nishkadg.linux@gmail.com
Signed-off-by: Stephen Boyd <sboyd@kernel.org>
drivers/clk/st/clk-flexgen.c

index d18e49b4976f5377726f14a145c910e1df451a3d..4413b6e04a8ecb157883b54b650f1cb12602efff 100644 (file)
@@ -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;