public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] clk: st: Fix memory leak
@ 2014-04-22 13:15 Valentin Ilie
  2014-05-06  9:29 ` Valentin Ilie
  2014-05-23 22:13 ` Mike Turquette
  0 siblings, 2 replies; 5+ messages in thread
From: Valentin Ilie @ 2014-04-22 13:15 UTC (permalink / raw)
  To: mturquette, pankaj.dev, gabriel.fernandez; +Cc: linux-kernel, Valentin Ilie

When it fails to allocate div, gate should be free'd before return

Signed-off-by: Valentin Ilie <valentin.ilie@gmail.com>
---
 drivers/clk/st/clkgen-pll.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/clk/st/clkgen-pll.c b/drivers/clk/st/clkgen-pll.c
index bca0a0b..a886702 100644
--- a/drivers/clk/st/clkgen-pll.c
+++ b/drivers/clk/st/clkgen-pll.c
@@ -521,8 +521,10 @@ static struct clk * __init clkgen_odf_register(const char *parent_name,
 	gate->lock = odf_lock;
 
 	div = kzalloc(sizeof(*div), GFP_KERNEL);
-	if (!div)
+	if (!div) {
+		kfree(gate);
 		return ERR_PTR(-ENOMEM);
+	}
 
 	div->flags = CLK_DIVIDER_ONE_BASED | CLK_DIVIDER_ALLOW_ZERO;
 	div->reg = reg + pll_data->odf[odf].offset;
-- 
1.8.3.2


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

end of thread, other threads:[~2014-05-23 22:14 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-04-22 13:15 [PATCH] clk: st: Fix memory leak Valentin Ilie
2014-05-06  9:29 ` Valentin Ilie
2014-05-06 12:32   ` Gabriel Fernandez
2014-05-21 12:46     ` Valentin Ilie
2014-05-23 22:13 ` Mike Turquette

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox