Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Nishka Dasgupta and committed by
Stephen Boyd
d55841ce 5911dba5

+4 -1
+4 -1
drivers/clk/davinci/pll.c
··· 778 778 int i; 779 779 780 780 clk_data = kzalloc(sizeof(*clk_data), GFP_KERNEL); 781 - if (!clk_data) 781 + if (!clk_data) { 782 + of_node_put(child); 782 783 return -ENOMEM; 784 + } 783 785 784 786 clks = kmalloc_array(n_clks, sizeof(*clks), GFP_KERNEL); 785 787 if (!clks) { 786 788 kfree(clk_data); 789 + of_node_put(child); 787 790 return -ENOMEM; 788 791 } 789 792