clk: st: fix memory leak on gate
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.
Signed-off-by Colin Ian King <[email protected]>
--- drivers/clk/st/clkgen-pll.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/clk/st/clkgen-pll.c +3 -1
@@ -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