* [PATCH] OMAP: hsmmc: fix memory leak
@ 2010-02-08 12:33 Aaro Koskinen
2010-02-09 23:17 ` Tony Lindgren
2010-02-10 13:28 ` Artem Bityutskiy
0 siblings, 2 replies; 7+ messages in thread
From: Aaro Koskinen @ 2010-02-08 12:33 UTC (permalink / raw)
To: linux-omap, tony; +Cc: adrian.hunter, jarkko.lavinen
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/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
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH] OMAP: hsmmc: fix memory leak
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 13:28 ` Artem Bityutskiy
1 sibling, 1 reply; 7+ messages in thread
From: Tony Lindgren @ 2010-02-09 23:17 UTC (permalink / raw)
To: Aaro Koskinen; +Cc: linux-omap, adrian.hunter, jarkko.lavinen
* 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
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] OMAP: hsmmc: fix memory leak
2010-02-09 23:17 ` Tony Lindgren
@ 2010-02-10 12:28 ` Aaro Koskinen
2010-02-10 17:22 ` Tony Lindgren
0 siblings, 1 reply; 7+ messages in thread
From: Aaro Koskinen @ 2010-02-10 12:28 UTC (permalink / raw)
To: ext Tony Lindgren
Cc: Koskinen Aaro (Nokia-D/Helsinki),
linux-omap, Hunter Adrian (Nokia-D/Helsinki),
Lavinen Jarkko (Nokia-D/Helsinki)
[-- Attachment #1: Type: TEXT/PLAIN, Size: 2001 bytes --]
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).
...
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
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: patch --]
[-- Type: TEXT/x-diff; name=0001-OMAP-hsmmc-fix-memory-leak.patch, Size: 1521 bytes --]
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
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH] OMAP: hsmmc: fix memory leak
2010-02-08 12:33 [PATCH] OMAP: hsmmc: fix memory leak Aaro Koskinen
2010-02-09 23:17 ` Tony Lindgren
@ 2010-02-10 13:28 ` Artem Bityutskiy
2010-02-10 17:21 ` Tony Lindgren
1 sibling, 1 reply; 7+ messages in thread
From: Artem Bityutskiy @ 2010-02-10 13:28 UTC (permalink / raw)
To: Aaro Koskinen; +Cc: linux-omap, tony, adrian.hunter, jarkko.lavinen
On Mon, 2010-02-08 at 14:33 +0200, Aaro Koskinen wrote:
> 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>
You forgot to add:
Acked-by: Adrian Hunter <adrian.hunter@nokia.com>
--
Best Regards,
Artem Bityutskiy (Артём Битюцкий)
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] OMAP: hsmmc: fix memory leak
2010-02-10 13:28 ` Artem Bityutskiy
@ 2010-02-10 17:21 ` Tony Lindgren
0 siblings, 0 replies; 7+ messages in thread
From: Tony Lindgren @ 2010-02-10 17:21 UTC (permalink / raw)
To: Artem Bityutskiy; +Cc: Aaro Koskinen, linux-omap, adrian.hunter, jarkko.lavinen
* Artem Bityutskiy <dedekind1@gmail.com> [100210 05:26]:
> On Mon, 2010-02-08 at 14:33 +0200, Aaro Koskinen wrote:
> > 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>
>
> You forgot to add:
>
> Acked-by: Adrian Hunter <adrian.hunter@nokia.com>
Thanks, I'll add that.
Tony
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] OMAP: hsmmc: fix memory leak
2010-02-10 12:28 ` Aaro Koskinen
@ 2010-02-10 17:22 ` Tony Lindgren
0 siblings, 0 replies; 7+ messages in thread
From: Tony Lindgren @ 2010-02-10 17:22 UTC (permalink / raw)
To: Aaro Koskinen
Cc: linux-omap, Hunter Adrian (Nokia-D/Helsinki),
Lavinen Jarkko (Nokia-D/Helsinki),
linux-arm-kernel
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
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH] OMAP: hsmmc: fix memory leak
@ 2010-02-10 17:22 ` Tony Lindgren
0 siblings, 0 replies; 7+ messages in thread
From: Tony Lindgren @ 2010-02-10 17:22 UTC (permalink / raw)
To: linux-arm-kernel
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
>
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2010-02-10 17:22 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
2010-02-10 17:22 ` Tony Lindgren
2010-02-10 13:28 ` Artem Bityutskiy
2010-02-10 17:21 ` Tony Lindgren
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.