[PATCH 12/14] mmc: bcm2835: Handle error case of of_get_address

Stefan Wahren stefan.wahren at i2se.com
Sat Jan 7 04:51:12 PST 2017


The function of_get_address could return NULL. So we better
handle this error case during probe.

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

diff --git a/drivers/mmc/host/bcm2835.c b/drivers/mmc/host/bcm2835.c
index 21beda8..d1ba862 100644
--- a/drivers/mmc/host/bcm2835.c
+++ b/drivers/mmc/host/bcm2835.c
@@ -1422,6 +1422,7 @@ static int bcm2835_probe(struct platform_device *pdev)
 	struct resource *iomem;
 	struct bcm2835_host *host;
 	struct mmc_host *mmc;
+	const __be32 *regaddr_p;
 	int ret;
 
 	dev_dbg(dev, "%s\n", __func__);
@@ -1449,8 +1450,14 @@ static int bcm2835_probe(struct platform_device *pdev)
 	/* Parse OF address directly to get the physical address for
 	 * DMA to our registers.
 	 */
-	host->phys_addr = be32_to_cpup(of_get_address(pdev->dev.of_node, 0,
-						      NULL, NULL));
+	regaddr_p = of_get_address(pdev->dev.of_node, 0, NULL, NULL);
+	if (!regaddr_p) {
+		dev_err(dev, "Can't get phys address\n");
+		ret = -EINVAL;
+		goto err;
+	}
+
+	host->phys_addr = be32_to_cpup(regaddr_p);
 
 	dev_dbg(dev, " - ioaddr %lx, iomem->start %lx, phys_addr %lx\n",
 		(unsigned long)host->ioaddr,
-- 
1.7.9.5




More information about the linux-rpi-kernel mailing list