[PATCH 05/15] mmc: bcm2835: Handle error cases during probe

Stefan Wahren stefan.wahren at i2se.com
Tue Feb 7 12:45:44 PST 2017


The functions mmc_of_parse and mmc_add_host can fail. So handle
the return value.

Signed-off-by: Stefan Wahren <stefan.wahren at i2se.com>
---
 drivers/mmc/host/bcm2835.c |   10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/drivers/mmc/host/bcm2835.c b/drivers/mmc/host/bcm2835.c
index 51cf428..752a726 100644
--- a/drivers/mmc/host/bcm2835.c
+++ b/drivers/mmc/host/bcm2835.c
@@ -1369,7 +1369,11 @@ int bcm2835_add_host(struct bcm2835_host *host)
 		return ret;
 	}
 
-	mmc_add_host(mmc);
+	ret = mmc_add_host(mmc);
+	if (ret) {
+		free_irq(host->irq, host);
+		return ret;
+	}
 
 	pio_limit_string[0] = '\0';
 	if (host->use_dma && (host->pio_limit > 0))
@@ -1455,7 +1459,9 @@ static int bcm2835_probe(struct platform_device *pdev)
 		(unsigned long)host->max_clk,
 		(int)host->irq);
 
-	mmc_of_parse(mmc);
+	ret = mmc_of_parse(mmc);
+	if (ret)
+		goto err;
 
 	ret = bcm2835_add_host(host);
 	if (ret)
-- 
1.7.9.5




More information about the linux-rpi-kernel mailing list