mmc: core: fix memory leak in mmc_add_host
authorWolfram Sang <w.sang@pengutronix.de>
Mon, 11 Apr 2011 04:11:29 +0000 (06:11 +0200)
committerChris Ball <cjb@laptop.org>
Wed, 25 May 2011 01:00:50 +0000 (21:00 -0400)
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>
Signed-off-by: Chris Ball <cjb@laptop.org>
drivers/mmc/core/host.c

index 2b200c1cfbba151a3348706d6a61668280119b0a..6714ea4e46ea20d26d3fcf80029a1b12047fe9ed 100644 (file)
@@ -324,12 +324,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