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>

authored by Aaro Koskinen and committed by Tony Lindgren a6c7fdd2 80e1e823

+6 -1
+6 -1
arch/arm/mach-omap2/mmc-twl4030.c
··· 408 408 { 409 409 struct twl4030_hsmmc_info *c; 410 410 int nr_hsmmc = ARRAY_SIZE(hsmmc_data); 411 + int i; 411 412 412 413 if (cpu_is_omap2430()) { 413 414 control_pbias_offset = OMAP243X_CONTROL_PBIAS_LITE; ··· 435 434 mmc = kzalloc(sizeof(struct omap_mmc_platform_data), GFP_KERNEL); 436 435 if (!mmc) { 437 436 pr_err("Cannot allocate memory for mmc device!\n"); 438 - return; 437 + goto done; 439 438 } 440 439 441 440 if (c->name) ··· 533 532 continue; 534 533 c->dev = mmc->dev; 535 534 } 535 + 536 + done: 537 + for (i = 0; i < nr_hsmmc; i++) 538 + kfree(hsmmc_data[i]); 536 539 } 537 540 538 541 #endif