Skip to content

Commit

Permalink
clk: st: Fix memory leak
Browse files Browse the repository at this point in the history
When it fails to allocate div, gate should be free'd before return

Signed-off-by: Valentin Ilie <valentin.ilie@gmail.com>
Signed-off-by: Mike Turquette <mturquette@linaro.org>
  • Loading branch information
vilie authored and Mike Turquette committed May 23, 2014
1 parent fe52e75 commit 72b1c2c
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion drivers/clk/st/clkgen-pll.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 72b1c2c

Please sign in to comment.