Skip to contentSkip to conversation

mmc: mtk-sd: check for valid optional memory resource

PATCH In review Fabien Parent 2 participants 2 messages Apr 3, 2019 – Apr 11, 2019

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 mmc: mtk-sd: check for valid optional memory resource

'top_base' memory region is optional. Check that the resource is valid before using it. This avoid getting a "invalid resource" error message printed by the kernel.

---

V2:
Fix invalid condition: check against 'res' variable instead of 'ret'.

---
 drivers/mmc/host/mtk-sd.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/mmc/host/mtk-sd.c +5 -3
index 833ef0590af8..61bf8704491c 100644
@@ -2123,9 +2123,11 @@ static int msdc_drv_probe(struct platform_device *pdev)
 	}
 
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
-	host->top_base = devm_ioremap_resource(&pdev->dev, res);
-	if (IS_ERR(host->top_base))
-		host->top_base = NULL;
+	if (res) {
+		host->top_base = devm_ioremap_resource(&pdev->dev, res);
+		if (IS_ERR(host->top_base))
+			host->top_base = NULL;
+	}
 
 	ret = mmc_regulator_get_supply(mmc);
 	if (ret)
Signature · 1 line
2.20.1
#1 lore raw
Quoted 6 lines · Fabien Parent

'top_base' memory region is optional. Check that the resource is valid before using it. This avoid getting a "invalid resource" error message printed by the kernel.

Applied for next, thanks!

Kind regards
Uffe

Quoted 31 lines

---

V2:
Fix invalid condition: check against 'res' variable instead of 'ret'.

---
 drivers/mmc/host/mtk-sd.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/mmc/host/mtk-sd.c +5 -4
index 833ef0590af8..61bf8704491c 100644
@@ -2123,9 +2123,11 @@ static int msdc_drv_probe(struct platform_device *pdev)
        }
 
        res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
-       host->top_base = devm_ioremap_resource(&pdev->dev, res);
-       if (IS_ERR(host->top_base))
-               host->top_base = NULL;
+       if (res) {
+               host->top_base = devm_ioremap_resource(&pdev->dev, res);
+               if (IS_ERR(host->top_base))
+                       host->top_base = NULL;
+       }
 
        ret = mmc_regulator_get_supply(mmc);
        if (ret)
--

2.20.1