linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: rjui@broadcom.com (Ray Jui)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 1/2] clk: iproc: fix memory leak from clock name
Date: Mon, 29 Jun 2015 14:33:13 -0700	[thread overview]
Message-ID: <5591B999.7070400@broadcom.com> (raw)
In-Reply-To: <1435613410-18698-2-git-send-email-rjui@broadcom.com>

+ Michael's new email

On 6/29/2015 2:30 PM, Ray Jui wrote:
> of_property_read_string_index takes array of pointers and assign them to
> strings read from device tree property. No additional memory allocation
> is needed prior to calling of_property_read_string_index. In fact, since
> the array of pointers will be re-assigned to other strings, any memory
> that it points to prior to calling of_property_read_string_index will be
> leaked
> 
> Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
> Signed-off-by: Ray Jui <rjui@broadcom.com>
> ---
>  drivers/clk/bcm/clk-iproc-asiu.c |    6 +-----
>  drivers/clk/bcm/clk-iproc-pll.c  |    8 +-------
>  2 files changed, 2 insertions(+), 12 deletions(-)
> 
> diff --git a/drivers/clk/bcm/clk-iproc-asiu.c b/drivers/clk/bcm/clk-iproc-asiu.c
> index e19c09c..f630e1b 100644
> --- a/drivers/clk/bcm/clk-iproc-asiu.c
> +++ b/drivers/clk/bcm/clk-iproc-asiu.c
> @@ -222,10 +222,6 @@ void __init iproc_asiu_setup(struct device_node *node,
>  		struct iproc_asiu_clk *asiu_clk;
>  		const char *clk_name;
>  
> -		clk_name = kzalloc(IPROC_CLK_NAME_LEN, GFP_KERNEL);
> -		if (WARN_ON(!clk_name))
> -			goto err_clk_register;
> -
>  		ret = of_property_read_string_index(node, "clock-output-names",
>  						    i, &clk_name);
>  		if (WARN_ON(ret))
> @@ -259,7 +255,7 @@ void __init iproc_asiu_setup(struct device_node *node,
>  
>  err_clk_register:
>  	for (i = 0; i < num_clks; i++)
> -		kfree(asiu->clks[i].name);
> +		clk_unregister(asiu->clk_data.clks[i]);
>  	iounmap(asiu->gate_base);
>  
>  err_iomap_gate:
> diff --git a/drivers/clk/bcm/clk-iproc-pll.c b/drivers/clk/bcm/clk-iproc-pll.c
> index 46fb84b..a8d971b 100644
> --- a/drivers/clk/bcm/clk-iproc-pll.c
> +++ b/drivers/clk/bcm/clk-iproc-pll.c
> @@ -655,10 +655,6 @@ void __init iproc_pll_clk_setup(struct device_node *node,
>  		memset(&init, 0, sizeof(init));
>  		parent_name = node->name;
>  
> -		clk_name = kzalloc(IPROC_CLK_NAME_LEN, GFP_KERNEL);
> -		if (WARN_ON(!clk_name))
> -			goto err_clk_register;
> -
>  		ret = of_property_read_string_index(node, "clock-output-names",
>  						    i, &clk_name);
>  		if (WARN_ON(ret))
> @@ -690,10 +686,8 @@ void __init iproc_pll_clk_setup(struct device_node *node,
>  	return;
>  
>  err_clk_register:
> -	for (i = 0; i < num_clks; i++) {
> -		kfree(pll->clks[i].name);
> +	for (i = 0; i < num_clks; i++)
>  		clk_unregister(pll->clk_data.clks[i]);
> -	}
>  
>  err_pll_register:
>  	if (pll->asiu_base)
> 

  reply	other threads:[~2015-06-29 21:33 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-29 21:30 [PATCH 0/2] iProc clock driver fixes Ray Jui
2015-06-29 21:30 ` [PATCH 1/2] clk: iproc: fix memory leak from clock name Ray Jui
2015-06-29 21:33   ` Ray Jui [this message]
2015-06-29 21:30 ` [PATCH 2/2] clk: iproc: fix bit manipulation arithmetic Ray Jui
2015-06-29 21:33   ` Ray Jui
2015-06-29 21:32 ` [PATCH 0/2] iProc clock driver fixes Ray Jui
2015-07-02 16:56   ` Stephen Boyd

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5591B999.7070400@broadcom.com \
    --to=rjui@broadcom.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).