linux-mmc.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Wolfram Sang <w.sang@pengutronix.de>
To: linux-mmc@vger.kernel.org
Cc: Chris Ball <cjb@laptop.org>,
	linus.walleij@linaro.org, Wolfram Sang <w.sang@pengutronix.de>
Subject: [PATCH] mmc: host: fix memory leak in mmc_add_host
Date: Mon, 11 Apr 2011 06:11:29 +0200	[thread overview]
Message-ID: <1302495089-23699-1-git-send-email-w.sang@pengutronix.de> (raw)

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


             reply	other threads:[~2011-04-11  4:11 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-04-11  4:11 Wolfram Sang [this message]
2011-04-11 21:25 ` [PATCH] mmc: host: fix memory leak in mmc_add_host Chris Ball

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1302495089-23699-1-git-send-email-w.sang@pengutronix.de \
    --to=w.sang@pengutronix.de \
    --cc=cjb@laptop.org \
    --cc=linus.walleij@linaro.org \
    --cc=linux-mmc@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).