Re: [PATCH] clk: st: Fix memory leak

2014-05-23 Thread Mike Turquette
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 

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
> 
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] clk: st: Fix memory leak

2014-05-23 Thread Mike Turquette
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.i...@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
 
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] clk: st: Fix memory leak

2014-05-21 Thread Valentin Ilie
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  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  wrote:
>>>
>>> When it fails to allocate div, gate should be free'd before return
>>>
>>> Signed-off-by: Valentin Ilie 
>>> ---
>>>   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
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] clk: st: Fix memory leak

2014-05-21 Thread Valentin Ilie
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.fernan...@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.i...@gmail.com wrote:

 When it fails to allocate div, gate should be free'd before return

 Signed-off-by: Valentin Ilie valentin.i...@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
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] clk: st: Fix memory leak

2014-05-06 Thread Gabriel Fernandez

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  wrote:

When it fails to allocate div, gate should be free'd before return

Signed-off-by: Valentin Ilie 
---
  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?



--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] clk: st: Fix memory leak

2014-05-06 Thread Valentin Ilie
On 22 April 2014 16:15, Valentin Ilie  wrote:
> When it fails to allocate div, gate should be free'd before return
>
> Signed-off-by: Valentin Ilie 
> ---
>  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
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] clk: st: Fix memory leak

2014-05-06 Thread Valentin Ilie
On 22 April 2014 16:15, Valentin Ilie valentin.i...@gmail.com wrote:
 When it fails to allocate div, gate should be free'd before return

 Signed-off-by: Valentin Ilie valentin.i...@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
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] clk: st: Fix memory leak

2014-05-06 Thread Gabriel Fernandez

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.i...@gmail.com wrote:

When it fails to allocate div, gate should be free'd before return

Signed-off-by: Valentin Ilie valentin.i...@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?



--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] clk: st: fix memory leak on gate

2014-04-22 Thread Colin King
From: Colin Ian King 

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 
---
 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.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] clk: st: Fix memory leak

2014-04-22 Thread Valentin Ilie
When it fails to allocate div, gate should be free'd before return

Signed-off-by: Valentin Ilie 
---
 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

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] clk: st: Fix memory leak

2014-04-22 Thread Valentin Ilie
When it fails to allocate div, gate should be free'd before return

Signed-off-by: Valentin Ilie valentin.i...@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

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] clk: st: fix memory leak on gate

2014-04-22 Thread Colin King
From: Colin Ian King colin.k...@canonical.com

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 colin.k...@canonical.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.9.1

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/