* [PATCH] mmc: host: fix memory leak in mmc_add_host
@ 2011-04-11 4:11 Wolfram Sang
2011-04-11 21:25 ` Chris Ball
0 siblings, 1 reply; 2+ messages in thread
From: Wolfram Sang @ 2011-04-11 4:11 UTC (permalink / raw)
To: linux-mmc; +Cc: Chris Ball, linus.walleij, Wolfram Sang
led_trigger_register_simple() allocates memory which must not be leaked
in the error-path of mmc_add_host. Move it past the only error-check in
the function.
Signed-off-by: Wolfram Sang <w.sang@pengutronix.de>
---
I don't see any reason why it needs to be called before device_add.
drivers/mmc/core/host.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/mmc/core/host.c b/drivers/mmc/core/host.c
index 461e6a1..b29d3e8 100644
--- a/drivers/mmc/core/host.c
+++ b/drivers/mmc/core/host.c
@@ -325,12 +325,12 @@ int mmc_add_host(struct mmc_host *host)
WARN_ON((host->caps & MMC_CAP_SDIO_IRQ) &&
!host->ops->enable_sdio_irq);
- led_trigger_register_simple(dev_name(&host->class_dev), &host->led);
-
err = device_add(&host->class_dev);
if (err)
return err;
+ led_trigger_register_simple(dev_name(&host->class_dev), &host->led);
+
#ifdef CONFIG_DEBUG_FS
mmc_add_host_debugfs(host);
#endif
--
1.7.2.5
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] mmc: host: fix memory leak in mmc_add_host
2011-04-11 4:11 [PATCH] mmc: host: fix memory leak in mmc_add_host Wolfram Sang
@ 2011-04-11 21:25 ` Chris Ball
0 siblings, 0 replies; 2+ messages in thread
From: Chris Ball @ 2011-04-11 21:25 UTC (permalink / raw)
To: Wolfram Sang; +Cc: linux-mmc, linus.walleij
Hi Wolfram,
On Mon, Apr 11 2011, Wolfram Sang wrote:
> led_trigger_register_simple() allocates memory which must not be leaked
> in the error-path of mmc_add_host. Move it past the only error-check in
> the function.
>
> Signed-off-by: Wolfram Sang <w.sang@pengutronix.de>
> ---
>
> I don't see any reason why it needs to be called before device_add.
>
> drivers/mmc/core/host.c | 4 ++--
> 1 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/mmc/core/host.c b/drivers/mmc/core/host.c
> index 461e6a1..b29d3e8 100644
> --- a/drivers/mmc/core/host.c
> +++ b/drivers/mmc/core/host.c
> @@ -325,12 +325,12 @@ int mmc_add_host(struct mmc_host *host)
> WARN_ON((host->caps & MMC_CAP_SDIO_IRQ) &&
> !host->ops->enable_sdio_irq);
>
> - led_trigger_register_simple(dev_name(&host->class_dev), &host->led);
> -
> err = device_add(&host->class_dev);
> if (err)
> return err;
>
> + led_trigger_register_simple(dev_name(&host->class_dev), &host->led);
> +
> #ifdef CONFIG_DEBUG_FS
> mmc_add_host_debugfs(host);
> #endif
Thanks, pushed to mmc-next for .40.
- Chris.
--
Chris Ball <cjb@laptop.org> <http://printf.net/>
One Laptop Per Child
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2011-04-11 21:20 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-04-11 4:11 [PATCH] mmc: host: fix memory leak in mmc_add_host Wolfram Sang
2011-04-11 21:25 ` Chris Ball
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).