From: Tony Lindgren <tony@atomide.com>
To: Aaro Koskinen <aaro.koskinen@nokia.com>
Cc: linux-omap@vger.kernel.org, adrian.hunter@nokia.com,
jarkko.lavinen@nokia.com
Subject: Re: [PATCH] OMAP: hsmmc: fix memory leak
Date: Tue, 9 Feb 2010 15:17:32 -0800 [thread overview]
Message-ID: <20100209231732.GM21755@atomide.com> (raw)
In-Reply-To: <1265632385-27448-1-git-send-email-aaro.koskinen@nokia.com>
* 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.
Regards,
Tony
> Signed-off-by: Aaro Koskinen <aaro.koskinen@nokia.com>
> ---
> arch/arm/mach-omap2/hsmmc.c | 7 ++++++-
> 1 files changed, 6 insertions(+), 1 deletions(-)
>
> diff --git a/arch/arm/mach-omap2/hsmmc.c b/arch/arm/mach-omap2/hsmmc.c
> index 1156b28..9ad2295 100644
> --- a/arch/arm/mach-omap2/hsmmc.c
> +++ b/arch/arm/mach-omap2/hsmmc.c
> @@ -145,6 +145,7 @@ void __init omap2_hsmmc_init(struct omap2_hsmmc_info *controllers)
> {
> struct omap2_hsmmc_info *c;
> int nr_hsmmc = ARRAY_SIZE(hsmmc_data);
> + int i;
>
> if (cpu_is_omap2430()) {
> control_pbias_offset = OMAP243X_CONTROL_PBIAS_LITE;
> @@ -171,7 +172,7 @@ void __init omap2_hsmmc_init(struct omap2_hsmmc_info *controllers)
> GFP_KERNEL);
> if (!mmc) {
> pr_err("Cannot allocate memory for mmc device!\n");
> - return;
> + goto done;
> }
>
> if (c->name)
> @@ -256,6 +257,10 @@ void __init omap2_hsmmc_init(struct omap2_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
>
next prev parent reply other threads:[~2010-02-09 23:16 UTC|newest]
Thread overview: 7+ 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 [this message]
2010-02-10 12:28 ` Aaro Koskinen
2010-02-10 17:22 ` Tony Lindgren
2010-02-10 17:22 ` Tony Lindgren
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=20100209231732.GM21755@atomide.com \
--to=tony@atomide.com \
--cc=aaro.koskinen@nokia.com \
--cc=adrian.hunter@nokia.com \
--cc=jarkko.lavinen@nokia.com \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.