diff options
| author | Aaro Koskinen <aaro.koskinen@nokia.com> | 2010-02-04 06:06:59 -0500 |
|---|---|---|
| committer | Tony Lindgren <tony@atomide.com> | 2010-02-10 12:20:33 -0500 |
| commit | a6c7fdd29350a74ba5f76809436de9c3d6763009 (patch) | |
| tree | 0bd269342ae913bfc760453c57462558aa74e10d | |
| parent | 80e1e823989ec44d8e35bdfddadbddcffec90424 (diff) | |
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>
Acked-by: Adrian Hunter <adrian.hunter@nokia.com>
Signed-off-by: Tony Lindgren <tony@atomide.com>
| -rw-r--r-- | 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 0c3c72d934bf..8afe9dd3f150 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) | |||
| 408 | { | 408 | { |
| 409 | struct twl4030_hsmmc_info *c; | 409 | struct twl4030_hsmmc_info *c; |
| 410 | int nr_hsmmc = ARRAY_SIZE(hsmmc_data); | 410 | int nr_hsmmc = ARRAY_SIZE(hsmmc_data); |
| 411 | int i; | ||
| 411 | 412 | ||
| 412 | if (cpu_is_omap2430()) { | 413 | if (cpu_is_omap2430()) { |
| 413 | control_pbias_offset = OMAP243X_CONTROL_PBIAS_LITE; | 414 | control_pbias_offset = OMAP243X_CONTROL_PBIAS_LITE; |
| @@ -434,7 +435,7 @@ void __init twl4030_mmc_init(struct twl4030_hsmmc_info *controllers) | |||
| 434 | mmc = kzalloc(sizeof(struct omap_mmc_platform_data), GFP_KERNEL); | 435 | mmc = kzalloc(sizeof(struct omap_mmc_platform_data), GFP_KERNEL); |
| 435 | if (!mmc) { | 436 | if (!mmc) { |
| 436 | pr_err("Cannot allocate memory for mmc device!\n"); | 437 | pr_err("Cannot allocate memory for mmc device!\n"); |
| 437 | return; | 438 | goto done; |
| 438 | } | 439 | } |
| 439 | 440 | ||
| 440 | if (c->name) | 441 | if (c->name) |
| @@ -532,6 +533,10 @@ void __init twl4030_mmc_init(struct twl4030_hsmmc_info *controllers) | |||
| 532 | continue; | 533 | continue; |
| 533 | c->dev = mmc->dev; | 534 | c->dev = mmc->dev; |
| 534 | } | 535 | } |
| 536 | |||
| 537 | done: | ||
| 538 | for (i = 0; i < nr_hsmmc; i++) | ||
| 539 | kfree(hsmmc_data[i]); | ||
| 535 | } | 540 | } |
| 536 | 541 | ||
| 537 | #endif | 542 | #endif |
