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

* Re: [PATCH] clk: st: Fix memory leak
  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-23 22:13 ` Mike Turquette
  1 sibling, 1 reply; 5+ messages in thread
From: Valentin Ilie @ 2014-05-06  9:29 UTC (permalink / raw)
  To: Mike Turquette, pankaj.dev, gabriel.fernandez; +Cc: linux-kernel, Valentin Ilie

On 22 April 2014 16:15, Valentin Ilie <valentin.ilie@gmail.com> wrote:
> 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
>

Can someone look into this?

-- 
Valentin Ilie

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

* Re: [PATCH] clk: st: Fix memory leak
  2014-05-06  9:29 ` Valentin Ilie
@ 2014-05-06 12:32   ` Gabriel Fernandez
  2014-05-21 12:46     ` Valentin Ilie
  0 siblings, 1 reply; 5+ messages in thread
From: Gabriel Fernandez @ 2014-05-06 12:32 UTC (permalink / raw)
  To: Valentin Ilie, Mike Turquette, pankaj.dev; +Cc: linux-kernel

Hi Valentin
Thanks for the patch, i agree with it.

Mike do you planned to integrate this patch ?

Gabriel.

Best Regards.


On 05/06/2014 11:29 AM, Valentin Ilie wrote:
> On 22 April 2014 16:15, Valentin Ilie <valentin.ilie@gmail.com> wrote:
>> 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
>>
> Can someone look into this?
>


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

* Re: [PATCH] clk: st: Fix memory leak
  2014-05-06 12:32   ` Gabriel Fernandez
@ 2014-05-21 12:46     ` Valentin Ilie
  0 siblings, 0 replies; 5+ messages in thread
From: Valentin Ilie @ 2014-05-21 12:46 UTC (permalink / raw)
  To: Gabriel Fernandez; +Cc: Mike Turquette, pankaj.dev, linux-kernel

Hi,

Even though the probability of getting a memory leak here is small I
think this patch is worth applying.

Thanks,
Valentin

On 6 May 2014 15:32, Gabriel Fernandez <gabriel.fernandez@st.com> wrote:
> Hi Valentin
> Thanks for the patch, i agree with it.
>
> Mike do you planned to integrate this patch ?
>
> Gabriel.
>
> Best Regards.
>
>
>
> On 05/06/2014 11:29 AM, Valentin Ilie wrote:
>>
>> On 22 April 2014 16:15, Valentin Ilie <valentin.ilie@gmail.com> wrote:
>>>
>>> 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
>>>
>> Can someone look into this?
>>
>



-- 
Valentin Ilie
+(40) 746 188 558

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

* Re: [PATCH] clk: st: Fix memory leak
  2014-04-22 13:15 [PATCH] clk: st: Fix memory leak Valentin Ilie
  2014-05-06  9:29 ` Valentin Ilie
@ 2014-05-23 22:13 ` Mike Turquette
  1 sibling, 0 replies; 5+ messages in thread
From: Mike Turquette @ 2014-05-23 22:13 UTC (permalink / raw)
  To: Valentin Ilie, pankaj.dev, gabriel.fernandez; +Cc: linux-kernel, Valentin Ilie

Quoting Valentin Ilie (2014-04-22 06:15:54)
> When it fails to allocate div, gate should be free'd before return
> 
> Signed-off-by: Valentin Ilie <valentin.ilie@gmail.com>

Taken into clk-fixes.

Regards,
Mike

> ---
>  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	[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