public inbox for linux-omap@vger.kernel.org
 help / color / mirror / Atom feed
From: Tony Lindgren <tony@atomide.com>
To: Aaro Koskinen <aaro.koskinen@nokia.com>
Cc: "linux-omap@vger.kernel.org" <linux-omap@vger.kernel.org>,
	"Hunter Adrian (Nokia-D/Helsinki)" <adrian.hunter@nokia.com>,
	"Lavinen Jarkko (Nokia-D/Helsinki)" <jarkko.lavinen@nokia.com>,
	linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH] OMAP: hsmmc: fix memory leak
Date: Wed, 10 Feb 2010 09:22:21 -0800	[thread overview]
Message-ID: <20100210172220.GT21755@atomide.com> (raw)
In-Reply-To: <alpine.DEB.2.00.1002101419540.20129@ak-desktop>

Hi

Added LAKML to Cc for a quick review there too.

* Aaro Koskinen <aaro.koskinen@nokia.com> [100210 04:25]:
> Hi,
> 
> On Wed, 10 Feb 2010, Tony Lindgren wrote:
> >* Aaro Koskinen <aaro.koskinen@nokia.com> [100208 04:29]:
> >>The platform data allocated with kmalloc() will become unreachable once
> >>the init is complete, so it should be freed. The problem was discovered
> >>by kmemleak.
> >
> >Looks like this is safe to do as platform_device_add_data does kmemdup
> >on the data.
> >
> >BTW, if you want to create a version for 2.6.33, we should still have
> >enough time to queue it as a fix. It's a very limited size leak though,
> >but still a leak.
> 
> The version for 2.6.33 is below (also attached).

Thanks, added to omap-fixes for 2.6.33.

Regards,

Tony

> 
> From: Aaro Koskinen <aaro.koskinen@nokia.com>
> Date: Thu, 4 Feb 2010 13:06:59 +0200
> Subject: [PATCH] OMAP: hsmmc: fix memory leak
> 
> The platform data allocated with kmalloc() will become unreachable once
> the init is complete, so it should be freed. The problem was discovered
> by kmemleak.
> 
> Signed-off-by: Aaro Koskinen <aaro.koskinen@nokia.com>
> ---
>  arch/arm/mach-omap2/mmc-twl4030.c |    7 ++++++-
>  1 files changed, 6 insertions(+), 1 deletions(-)
> 
> diff --git a/arch/arm/mach-omap2/mmc-twl4030.c b/arch/arm/mach-omap2/mmc-twl4030.c
> index 0c3c72d..8afe9dd 100644
> --- a/arch/arm/mach-omap2/mmc-twl4030.c
> +++ b/arch/arm/mach-omap2/mmc-twl4030.c
> @@ -408,6 +408,7 @@ void __init twl4030_mmc_init(struct twl4030_hsmmc_info *controllers)
>  {
>  	struct twl4030_hsmmc_info *c;
>  	int nr_hsmmc = ARRAY_SIZE(hsmmc_data);
> +	int i;
> 
>  	if (cpu_is_omap2430()) {
>  		control_pbias_offset = OMAP243X_CONTROL_PBIAS_LITE;
> @@ -434,7 +435,7 @@ void __init twl4030_mmc_init(struct twl4030_hsmmc_info *controllers)
>  		mmc = kzalloc(sizeof(struct omap_mmc_platform_data), GFP_KERNEL);
>  		if (!mmc) {
>  			pr_err("Cannot allocate memory for mmc device!\n");
> -			return;
> +			goto done;
>  		}
> 
>  		if (c->name)
> @@ -532,6 +533,10 @@ void __init twl4030_mmc_init(struct twl4030_hsmmc_info *controllers)
>  			continue;
>  		c->dev = mmc->dev;
>  	}
> +
> +done:
> +	for (i = 0; i < nr_hsmmc; i++)
> +		kfree(hsmmc_data[i]);
>  }
> 
>  #endif
> -- 
> 1.5.6.5

> From 6d15f48ecc177bde18033af2884eb2c5ce53bfd7 Mon Sep 17 00:00:00 2001
> From: Aaro Koskinen <aaro.koskinen@nokia.com>
> Date: Thu, 4 Feb 2010 13:06:59 +0200
> Subject: [PATCH] OMAP: hsmmc: fix memory leak
> 
> The platform data allocated with kmalloc() will become unreachable once
> the init is complete, so it should be freed. The problem was discovered
> by kmemleak.
> 
> Signed-off-by: Aaro Koskinen <aaro.koskinen@nokia.com>
> ---
>  arch/arm/mach-omap2/mmc-twl4030.c |    7 ++++++-
>  1 files changed, 6 insertions(+), 1 deletions(-)
> 
> diff --git a/arch/arm/mach-omap2/mmc-twl4030.c b/arch/arm/mach-omap2/mmc-twl4030.c
> index 0c3c72d..8afe9dd 100644
> --- a/arch/arm/mach-omap2/mmc-twl4030.c
> +++ b/arch/arm/mach-omap2/mmc-twl4030.c
> @@ -408,6 +408,7 @@ void __init twl4030_mmc_init(struct twl4030_hsmmc_info *controllers)
>  {
>  	struct twl4030_hsmmc_info *c;
>  	int nr_hsmmc = ARRAY_SIZE(hsmmc_data);
> +	int i;
>  
>  	if (cpu_is_omap2430()) {
>  		control_pbias_offset = OMAP243X_CONTROL_PBIAS_LITE;
> @@ -434,7 +435,7 @@ void __init twl4030_mmc_init(struct twl4030_hsmmc_info *controllers)
>  		mmc = kzalloc(sizeof(struct omap_mmc_platform_data), GFP_KERNEL);
>  		if (!mmc) {
>  			pr_err("Cannot allocate memory for mmc device!\n");
> -			return;
> +			goto done;
>  		}
>  
>  		if (c->name)
> @@ -532,6 +533,10 @@ void __init twl4030_mmc_init(struct twl4030_hsmmc_info *controllers)
>  			continue;
>  		c->dev = mmc->dev;
>  	}
> +
> +done:
> +	for (i = 0; i < nr_hsmmc; i++)
> +		kfree(hsmmc_data[i]);
>  }
>  
>  #endif
> -- 
> 1.5.6.5
> 


  reply	other threads:[~2010-02-10 17:21 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-02-08 12:33 [PATCH] OMAP: hsmmc: fix memory leak Aaro Koskinen
2010-02-09 23:17 ` Tony Lindgren
2010-02-10 12:28   ` Aaro Koskinen
2010-02-10 17:22     ` Tony Lindgren [this message]
2010-02-10 13:28 ` Artem Bityutskiy
2010-02-10 17:21   ` Tony Lindgren

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=20100210172220.GT21755@atomide.com \
    --to=tony@atomide.com \
    --cc=aaro.koskinen@nokia.com \
    --cc=adrian.hunter@nokia.com \
    --cc=jarkko.lavinen@nokia.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-omap@vger.kernel.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