diff options
author | Nishka Dasgupta <nishkadg.linux@gmail.com> | 2019-08-04 19:28:24 +0300 |
---|---|---|
committer | Stephen Boyd <sboyd@kernel.org> | 2019-08-08 01:25:45 +0300 |
commit | d55841ce1115ce08614bde66a780211f4ea12ae1 (patch) | |
tree | 3fd5c8f9652512c568e60fcbf2a7c2b03011be41 /drivers/clk/davinci | |
parent | 5911dba556cf41a14907ed04b5636cf852b17933 (diff) | |
download | linux-d55841ce1115ce08614bde66a780211f4ea12ae1.tar.xz |
clk: davinci: pll: Add of_node_put() in of_davinci_pll_init()
The variable child in the function of_davinci_pll_init takes the value
of of_get_child_by_name, which gets a node but does not put it. If child
is not put before the function returns it may cause a memory leak. Hence
put child before two return statements.
Issue found with Coccinelle.
Signed-off-by: Nishka Dasgupta <nishkadg.linux@gmail.com>
Link: https://lkml.kernel.org/r/20190804162824.6338-1-nishkadg.linux@gmail.com
Signed-off-by: Stephen Boyd <sboyd@kernel.org>
Diffstat (limited to 'drivers/clk/davinci')
-rw-r--r-- | drivers/clk/davinci/pll.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/drivers/clk/davinci/pll.c b/drivers/clk/davinci/pll.c index 1c99e992d638..1ac11b6a47a3 100644 --- a/drivers/clk/davinci/pll.c +++ b/drivers/clk/davinci/pll.c @@ -778,12 +778,15 @@ int of_davinci_pll_init(struct device *dev, struct device_node *node, int i; clk_data = kzalloc(sizeof(*clk_data), GFP_KERNEL); - if (!clk_data) + if (!clk_data) { + of_node_put(child); return -ENOMEM; + } clks = kmalloc_array(n_clks, sizeof(*clks), GFP_KERNEL); if (!clks) { kfree(clk_data); + of_node_put(child); return -ENOMEM; } |