linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/1] clk/zynq: Fix possible memory leak
@ 2013-10-07  0:55 Felipe Pena
  2013-10-07  2:10 ` Baruch Siach
  2013-10-07 16:05 ` Sören Brinkmann
  0 siblings, 2 replies; 3+ messages in thread
From: Felipe Pena @ 2013-10-07  0:55 UTC (permalink / raw)
  To: Mike Turquette, Michal Simek, Stephen Boyd, Maxime Ripard,
	Sören Brinkmann
  Cc: linux-arm-kernel, linux-kernel, Felipe Pena

The zynq_clk_register_fclk function can leak memory (fclk_lock) when unable 
to alloc memory for fclk_gate_lock

Signed-off-by: Felipe Pena <felipensp@gmail.com>
---
 drivers/clk/zynq/clkc.c |    1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/clk/zynq/clkc.c b/drivers/clk/zynq/clkc.c
index cc40fe6..7ea4b5c 100644
--- a/drivers/clk/zynq/clkc.c
+++ b/drivers/clk/zynq/clkc.c
@@ -117,6 +117,7 @@ static void __init zynq_clk_register_fclk(enum zynq_clk fclk,
 		goto err;
 	fclk_gate_lock = kmalloc(sizeof(*fclk_gate_lock), GFP_KERNEL);
 	if (!fclk_gate_lock)
+		kfree(fclk_lock);
 		goto err;
 	spin_lock_init(fclk_lock);
 	spin_lock_init(fclk_gate_lock);
-- 
1.7.10.4


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

* Re: [PATCH 1/1] clk/zynq: Fix possible memory leak
  2013-10-07  0:55 [PATCH 1/1] clk/zynq: Fix possible memory leak Felipe Pena
@ 2013-10-07  2:10 ` Baruch Siach
  2013-10-07 16:05 ` Sören Brinkmann
  1 sibling, 0 replies; 3+ messages in thread
From: Baruch Siach @ 2013-10-07  2:10 UTC (permalink / raw)
  To: Felipe Pena
  Cc: Mike Turquette, Michal Simek, Stephen Boyd, Maxime Ripard,
	Sören Brinkmann, linux-kernel, linux-arm-kernel

Hi Felipe,

On Sun, Oct 06, 2013 at 09:55:17PM -0300, Felipe Pena wrote:
> The zynq_clk_register_fclk function can leak memory (fclk_lock) when unable 
> to alloc memory for fclk_gate_lock
> 
> Signed-off-by: Felipe Pena <felipensp@gmail.com>
> ---
>  drivers/clk/zynq/clkc.c |    1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/clk/zynq/clkc.c b/drivers/clk/zynq/clkc.c
> index cc40fe6..7ea4b5c 100644
> --- a/drivers/clk/zynq/clkc.c
> +++ b/drivers/clk/zynq/clkc.c
> @@ -117,6 +117,7 @@ static void __init zynq_clk_register_fclk(enum zynq_clk fclk,
>  		goto err;
>  	fclk_gate_lock = kmalloc(sizeof(*fclk_gate_lock), GFP_KERNEL);
>  	if (!fclk_gate_lock)
> +		kfree(fclk_lock);
>  		goto err;

Missing braces.

>  	spin_lock_init(fclk_lock);
>  	spin_lock_init(fclk_gate_lock);

baruch

-- 
     http://baruch.siach.name/blog/                  ~. .~   Tk Open Systems
=}------------------------------------------------ooO--U--Ooo------------{=
   - baruch@tkos.co.il - tel: +972.2.679.5364, http://www.tkos.co.il -

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

* Re: [PATCH 1/1] clk/zynq: Fix possible memory leak
  2013-10-07  0:55 [PATCH 1/1] clk/zynq: Fix possible memory leak Felipe Pena
  2013-10-07  2:10 ` Baruch Siach
@ 2013-10-07 16:05 ` Sören Brinkmann
  1 sibling, 0 replies; 3+ messages in thread
From: Sören Brinkmann @ 2013-10-07 16:05 UTC (permalink / raw)
  To: Felipe Pena
  Cc: Mike Turquette, Michal Simek, Stephen Boyd, Maxime Ripard,
	linux-arm-kernel, linux-kernel

On Sun, Oct 06, 2013 at 09:55:17PM -0300, Felipe Pena wrote:
> The zynq_clk_register_fclk function can leak memory (fclk_lock) when unable 
> to alloc memory for fclk_gate_lock
> 
> Signed-off-by: Felipe Pena <felipensp@gmail.com>
> ---
>  drivers/clk/zynq/clkc.c |    1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/clk/zynq/clkc.c b/drivers/clk/zynq/clkc.c
> index cc40fe6..7ea4b5c 100644
> --- a/drivers/clk/zynq/clkc.c
> +++ b/drivers/clk/zynq/clkc.c
> @@ -117,6 +117,7 @@ static void __init zynq_clk_register_fclk(enum zynq_clk fclk,
>  		goto err;
>  	fclk_gate_lock = kmalloc(sizeof(*fclk_gate_lock), GFP_KERNEL);
>  	if (!fclk_gate_lock)
> +		kfree(fclk_lock);
>  		goto err;

Looking at that function, the following calls to various clk_register_*
functions miss correct error handling as well. Therefore it might make
sense to consolidate this free in an error path at the bottom of the
function. That would make things easier when somebody wants to add more
error handling.

Other than that you're right and feel free to add my Acked-by, once you
have fixed the missing braces, Baruch pointed out.

	Sören



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

end of thread, other threads:[~2013-10-07 16:05 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-10-07  0:55 [PATCH 1/1] clk/zynq: Fix possible memory leak Felipe Pena
2013-10-07  2:10 ` Baruch Siach
2013-10-07 16:05 ` Sören Brinkmann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).