Skip to contentSkip to conversation

mmc: sdhci: add error checking for mmc_add_host

PATCH Superseded Jaehoon Chung 2 participants 3 messages Apr 4, 2011

Subsystems (2)

v1 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mmc: sdhci: add error checking for mmc_add_host

Sometimes we can't add the device,but we didn't check any error status. Need to check error status for mmc_add_host.

---
 drivers/mmc/host/sdhci.c |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)
drivers/mmc/host/sdhci.c +6 -1
index 9e15f41..9c777bc 100644
@@ -2025,7 +2025,9 @@ int sdhci_add_host(struct sdhci_host *host)
 
 	mmiowb();
 
-	mmc_add_host(mmc);
+	ret = mmc_add_host(mmc);
+	if (unlikely(ret))
+		goto err_free_mmc;
 
 	printk(KERN_INFO "%s: SDHCI controller on %s [%s] using %s\n",
 		mmc_hostname(mmc), host->hw_name, dev_name(mmc_dev(mmc)),
@@ -2041,6 +2043,9 @@ reset:
 	sdhci_reset(host, SDHCI_RESET_ALL);
 	free_irq(host->irq, host);
 #endif
+err_free_mmc:
+	mmc_free_host(host);
+
 untasklet:
 	tasklet_kill(&host->card_tasklet);
 	tasklet_kill(&host->finish_tasklet);
#1 lore raw
Quoted 2 lines · Jaehoon Chung

Sometimes we can't add the device,but we didn't check any error status. Need to check error status for mmc_add_host.

Thanks, this is correct, but...

drivers/mmc/host/sdhci.c int sdhci_add_host(struct sdhci_host *host) · line 2030

Quoted 4 lines
drivers/mmc/host/sdhci.c +3 -1
-	mmc_add_host(mmc);
+	ret = mmc_add_host(mmc);
+	if (unlikely(ret))
+		goto err_free_mmc;

... you are leaking the irq and the lcd_classdev here.

Regards,

Wolfram

Signature · 2 lines
Pengutronix e.K.                           | Wolfram Sang                |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
#2 lore raw
Quoted 4 lines · Wolfram Sang
Quoted 2 lines · Jaehoon Chung

Sometimes we can't add the device,but we didn't check any error status. Need to check error status for mmc_add_host.

Quoted 8 lines

Thanks, this is correct, but...

drivers/mmc/host/sdhci.c int sdhci_add_host(struct sdhci_host *host) · line 2030

Quoted 4 lines
drivers/mmc/host/sdhci.c +3 -1
-	mmc_add_host(mmc);
+	ret = mmc_add_host(mmc);
+	if (unlikely(ret))
+		goto err_free_mmc;

... you are leaking the irq and the lcd_classdev here.

Thanks for your comment, i will resend the patch.

Quoted 5 lines

Regards,

Wolfram