linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] clk: gpio: fix memory leak
@ 2015-12-23  6:33 Sudip Mukherjee
  2016-01-01  5:32 ` Michael Turquette
  0 siblings, 1 reply; 2+ messages in thread
From: Sudip Mukherjee @ 2015-12-23  6:33 UTC (permalink / raw)
  To: Michael Turquette, Stephen Boyd; +Cc: linux-kernel, linux-clk, Sudip Mukherjee

If we fail to allocate parent_name then we are returning but we missed
freeing data which has already been allocated.

Signed-off-by: Sudip Mukherjee <sudip@vectorindia.org>
---
 drivers/clk/clk-gpio.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/clk/clk-gpio.c b/drivers/clk/clk-gpio.c
index 335322d..c1baa89 100644
--- a/drivers/clk/clk-gpio.c
+++ b/drivers/clk/clk-gpio.c
@@ -294,8 +294,10 @@ static void __init of_gpio_clk_setup(struct device_node *node,
 	num_parents = of_clk_get_parent_count(node);
 
 	parent_names = kcalloc(num_parents, sizeof(char *), GFP_KERNEL);
-	if (!parent_names)
+	if (!parent_names) {
+		kfree(data);
 		return;
+	}
 
 	for (i = 0; i < num_parents; i++)
 		parent_names[i] = of_clk_get_parent_name(node, i);
-- 
1.9.1


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

* Re: [PATCH] clk: gpio: fix memory leak
  2015-12-23  6:33 [PATCH] clk: gpio: fix memory leak Sudip Mukherjee
@ 2016-01-01  5:32 ` Michael Turquette
  0 siblings, 0 replies; 2+ messages in thread
From: Michael Turquette @ 2016-01-01  5:32 UTC (permalink / raw)
  To: Sudip Mukherjee, Stephen Boyd; +Cc: linux-kernel, linux-clk, Sudip Mukherjee

Quoting Sudip Mukherjee (2015-12-22 22:33:59)
> If we fail to allocate parent_name then we are returning but we missed
> freeing data which has already been allocated.
> 
> Signed-off-by: Sudip Mukherjee <sudip@vectorindia.org>

Applied.

Thanks,
Mike

> ---
>  drivers/clk/clk-gpio.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/clk/clk-gpio.c b/drivers/clk/clk-gpio.c
> index 335322d..c1baa89 100644
> --- a/drivers/clk/clk-gpio.c
> +++ b/drivers/clk/clk-gpio.c
> @@ -294,8 +294,10 @@ static void __init of_gpio_clk_setup(struct device_node *node,
>         num_parents = of_clk_get_parent_count(node);
>  
>         parent_names = kcalloc(num_parents, sizeof(char *), GFP_KERNEL);
> -       if (!parent_names)
> +       if (!parent_names) {
> +               kfree(data);
>                 return;
> +       }
>  
>         for (i = 0; i < num_parents; i++)
>                 parent_names[i] = of_clk_get_parent_name(node, i);
> -- 
> 1.9.1
> 

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

end of thread, other threads:[~2016-01-01  5:32 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-12-23  6:33 [PATCH] clk: gpio: fix memory leak Sudip Mukherjee
2016-01-01  5:32 ` Michael Turquette

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