Skip to content

Commit

Permalink
mmc: core: fix memory leak in mmc_add_host
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: Chris Ball <[email protected]>
  • Loading branch information
Wolfram Sang authored and cjb committed May 25, 2011
1 parent b177bc9 commit f317dfe
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions drivers/mmc/core/host.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit f317dfe

Please sign in to comment.