Skip to contentSkip to conversation

clk: st: fix memory leak on gate

PATCH New Colin King 1 participant 1 message Apr 22, 2014 Common clk

lore
Share & tools
lore

Colin King

author
#0 lore raw

PATCH 1/1 clk: st: fix memory leak on gate

From: Colin Ian King <[email protected]>

cppcheck detected a memory leak:
[drivers/clk/st/clkgen-pll.c:525]: (error) Memory leak: gate

free gate on div allocation failure return path.

---
 drivers/clk/st/clkgen-pll.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/clk/st/clkgen-pll.c +3 -1
index bca0a0b..a886702 100644
@@ -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;
Signature · 1 line
1.9.1