All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] clk: davinci: pll: Add of_node_put() in of_davinci_pll_init()
@ 2019-08-04 16:28 Nishka Dasgupta
  2019-08-07 22:26 ` Stephen Boyd
  0 siblings, 1 reply; 2+ messages in thread
From: Nishka Dasgupta @ 2019-08-04 16:28 UTC (permalink / raw)
  To: david, nsekhar, mturquette, sboyd, linux-clk; +Cc: Nishka Dasgupta

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>
---
 drivers/clk/davinci/pll.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

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;
 		}
 
-- 
2.19.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] clk: davinci: pll: Add of_node_put() in of_davinci_pll_init()
  2019-08-04 16:28 [PATCH] clk: davinci: pll: Add of_node_put() in of_davinci_pll_init() Nishka Dasgupta
@ 2019-08-07 22:26 ` Stephen Boyd
  0 siblings, 0 replies; 2+ messages in thread
From: Stephen Boyd @ 2019-08-07 22:26 UTC (permalink / raw)
  To: Nishka Dasgupta, david, linux-clk, mturquette, nsekhar; +Cc: Nishka Dasgupta

Quoting Nishka Dasgupta (2019-08-04 09:28:24)
> 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>
> ---

Applied to clk-next


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-08-07 22:26 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-04 16:28 [PATCH] clk: davinci: pll: Add of_node_put() in of_davinci_pll_init() Nishka Dasgupta
2019-08-07 22:26 ` Stephen Boyd

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.