Skip to contentSkip to conversation

mmc: omap_hsmmc: ensure probe returns error upon resource failure

PATCH In review Kevin Hilman 3 participants 3 messages Jul 10, 2012 – Jul 21, 2012

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

PATCH 1/1 mmc: omap_hsmmc: ensure probe returns error upon resource failure

If platform_get_resource_by_name() fails, driver probe is aborted an should return an error so the driver is not bound to the device.

However, in the current error path of platform_get_resource_by_name(), probe returns zero since the return value (ret) is not properly set. With a zero return value, the driver core assumes probe was successful and will bind the driver to the device.

Fix this by ensuring that probe returns an error code in this failure path.

---
 drivers/mmc/host/omap_hsmmc.c |    2 ++
 1 file changed, 2 insertions(+)
drivers/mmc/host/omap_hsmmc.c +2 -0
index 389a3ee..19e60e9 100644
@@ -1931,6 +1931,7 @@ static int __devinit omap_hsmmc_probe(struct platform_device *pdev)
 	res = platform_get_resource_byname(pdev, IORESOURCE_DMA, "tx");
 	if (!res) {
 		dev_err(mmc_dev(host->mmc), "cannot get DMA TX channel\n");
+		ret = -ENXIO;
 		goto err_irq;
 	}
 	host->dma_line_tx = res->start;
@@ -1938,6 +1939,7 @@ static int __devinit omap_hsmmc_probe(struct platform_device *pdev)
 	res = platform_get_resource_byname(pdev, IORESOURCE_DMA, "rx");
 	if (!res) {
 		dev_err(mmc_dev(host->mmc), "cannot get DMA RX channel\n");
+		ret = -ENXIO;
 		goto err_irq;
 	}
 	host->dma_line_rx = res->start;
Signature · 1 line
1.7.9.2
Acked-by on v1 1/1
#1 lore raw
Quoted 8 lines · Kevin Hilman

If platform_get_resource_by_name() fails, driver probe is aborted an should return an error so the driver is not bound to the device.

However, in the current error path of platform_get_resource_by_name(), probe returns zero since the return value (ret) is not properly set. With a zero return value, the driver core assumes probe was successful and will bind the driver to the device.

Quoted 4 lines

Fix this by ensuring that probe returns an error code in this failure path.

Good catch.

Quoted 27 lines
---
 drivers/mmc/host/omap_hsmmc.c |    2 ++
 1 file changed, 2 insertions(+)
drivers/mmc/host/omap_hsmmc.c +2 -1
index 389a3ee..19e60e9 100644
@@ -1931,6 +1931,7 @@ static int __devinit omap_hsmmc_probe(struct platform_device *pdev)
        res = platform_get_resource_byname(pdev, IORESOURCE_DMA, "tx");
        if (!res) {
                dev_err(mmc_dev(host->mmc), "cannot get DMA TX channel\n");
+               ret = -ENXIO;
                goto err_irq;
        }
        host->dma_line_tx = res->start;
@@ -1938,6 +1939,7 @@ static int __devinit omap_hsmmc_probe(struct platform_device *pdev)
        res = platform_get_resource_byname(pdev, IORESOURCE_DMA, "rx");
        if (!res) {
                dev_err(mmc_dev(host->mmc), "cannot get DMA RX channel\n");
+               ret = -ENXIO;
                goto err_irq;
        }
        host->dma_line_rx = res->start;
--

1.7.9.2

#2 lore raw

Hi,

Quoted 9 lines · Venkatraman
Quoted 8 lines · Kevin Hilman

If platform_get_resource_by_name() fails, driver probe is aborted an should return an error so the driver is not bound to the device.

However, in the current error path of platform_get_resource_by_name(), probe returns zero since the return value (ret) is not properly set. With a zero return value, the driver core assumes probe was successful and will bind the driver to the device.

Quoted 7 lines
Quoted 4 lines

Fix this by ensuring that probe returns an error code in this failure path.

Good catch.

Thanks, pushed to mmc-next for 3.6.

- Chris.

Signature · 2 lines
Chris Ball   <[email protected]>   <http://printf.net/>
One Laptop Per Child