mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] mmc: omap_hsmmc: ensure probe returns error upon resource failure
@ 2012-07-10 23:40 Kevin Hilman
  2012-07-12  6:19 ` S, Venkatraman
  0 siblings, 1 reply; 3+ messages in thread
From: Kevin Hilman @ 2012-07-10 23:40 UTC (permalink / raw)
  To: Chris Ball, Venkatraman S, linux-mmc
  Cc: linux-omap, Balaji T K, Rajendra Nayak, Adrian Hunter, open list

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.

Signed-off-by: Kevin Hilman <khilman@ti.com>
---
 drivers/mmc/host/omap_hsmmc.c |    2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/mmc/host/omap_hsmmc.c b/drivers/mmc/host/omap_hsmmc.c
index 389a3ee..19e60e9 100644
--- a/drivers/mmc/host/omap_hsmmc.c
+++ b/drivers/mmc/host/omap_hsmmc.c
@@ -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


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] mmc: omap_hsmmc: ensure probe returns error upon resource failure
  2012-07-10 23:40 [PATCH] mmc: omap_hsmmc: ensure probe returns error upon resource failure Kevin Hilman
@ 2012-07-12  6:19 ` S, Venkatraman
  2012-07-21 23:23   ` Chris Ball
  0 siblings, 1 reply; 3+ messages in thread
From: S, Venkatraman @ 2012-07-12  6:19 UTC (permalink / raw)
  To: Kevin Hilman
  Cc: Chris Ball, linux-mmc, linux-omap, Balaji T K, Rajendra Nayak,
	Adrian Hunter, open list

On Wed, Jul 11, 2012 at 5:10 AM, Kevin Hilman <khilman@ti.com> wrote:
> 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.
>
> Signed-off-by: Kevin Hilman <khilman@ti.com>

Good catch.
Acked-by: Venkatraman S <svenkatr@ti.com>


> ---
>  drivers/mmc/host/omap_hsmmc.c |    2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/drivers/mmc/host/omap_hsmmc.c b/drivers/mmc/host/omap_hsmmc.c
> index 389a3ee..19e60e9 100644
> --- a/drivers/mmc/host/omap_hsmmc.c
> +++ b/drivers/mmc/host/omap_hsmmc.c
> @@ -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
>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] mmc: omap_hsmmc: ensure probe returns error upon resource failure
  2012-07-12  6:19 ` S, Venkatraman
@ 2012-07-21 23:23   ` Chris Ball
  0 siblings, 0 replies; 3+ messages in thread
From: Chris Ball @ 2012-07-21 23:23 UTC (permalink / raw)
  To: S, Venkatraman
  Cc: Kevin Hilman, linux-mmc, linux-omap, Balaji T K, Rajendra Nayak,
	Adrian Hunter, open list

Hi,

On Thu, Jul 12 2012, S, Venkatraman wrote:
> On Wed, Jul 11, 2012 at 5:10 AM, Kevin Hilman <khilman@ti.com> wrote:
>> 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.
>>
>> Signed-off-by: Kevin Hilman <khilman@ti.com>
>
> Good catch.
> Acked-by: Venkatraman S <svenkatr@ti.com>

Thanks, pushed to mmc-next for 3.6.

- Chris.
-- 
Chris Ball   <cjb@laptop.org>   <http://printf.net/>
One Laptop Per Child

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2012-07-21 23:23 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-07-10 23:40 [PATCH] mmc: omap_hsmmc: ensure probe returns error upon resource failure Kevin Hilman
2012-07-12  6:19 ` S, Venkatraman
2012-07-21 23:23   ` Chris Ball

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®