clk: st: Fix memory leak
PATCH 1/1 clk: st: Fix memory leak
When it fails to allocate div, gate should be free'd before return
--- 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.8.3.2
Quoted 24 lines · Valentin Ilie
When it fails to allocate div, gate should be free'd before return
Signed-off-by Valentin Ilie <[email protected]>--- drivers/clk/st/clkgen-pll.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)drivers/clk/st/clkgen-pll.c +3
-2@@ -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; --
Quoted 2 lines
1.8.3.2
Can someone look into this?
Signature · 1 line
Valentin Ilie
Hi Valentin
Thanks for the patch, i agree with it.
Mike do you planned to integrate this patch ?
Gabriel.
Best Regards.
Quoted 29 lines · Valentin Ilie
Quoted 24 lines · Valentin Ilie
When it fails to allocate div, gate should be free'd before return
Signed-off-by Valentin Ilie <[email protected]>--- drivers/clk/st/clkgen-pll.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)drivers/clk/st/clkgen-pll.c +3
-2@@ -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; --Quoted 2 lines
1.8.3.2
Can someone look into this?
Hi,
Even though the probability of getting a memory leak here is small I think this patch is worth applying.
Thanks,
Valentin
Quoted 45 lines · Gabriel Fernandez
Hi Valentin
Thanks for the patch, i agree with it.Mike do you planned to integrate this patch ?
Gabriel.
Best Regards.
Quoted 32 lines · Valentin Ilie
Quoted 25 lines · Valentin Ilie
When it fails to allocate div, gate should be free'd before return
Signed-off-by Valentin Ilie <[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(constchar *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;Quoted 3 lines
--
1.8.3.2Can someone look into this?
Signature · 2 lines
Valentin Ilie +(40) 746 188 558
Quoting Valentin Ilie (2014-04-22 06:15:54)
Quoted 3 lines
When it fails to allocate div, gate should be free'd before return
Signed-off-by Valentin Ilie <[email protected]>
Taken into clk-fixes.
Regards,
Mike
Quoted 23 lines
--- 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.8.3.2