2023-08-09 08:44:22

by Harshit Mogalapalli

[permalink] [raw]
Subject: [PATCH next v2 2/2] mmc: sunplus: Fix platform_get_irq() error checking

The platform_get_irq() function returns negative error codes on failure.

Fixes: 4e268fed8b18 ("mmc: Add mmc driver for Sunplus SP7021")
Reported-by: Dan Carpenter <[email protected]>
Closes: https://lore.kernel.org/all/[email protected]/
Signed-off-by: Harshit Mogalapalli <[email protected]>
---
v1->v2: Split into two patches as they are doing different things.

This is based on static analysis with smatch, only compile tested.
---
drivers/mmc/host/sunplus-mmc.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/mmc/host/sunplus-mmc.c b/drivers/mmc/host/sunplus-mmc.c
index 2bdebeb1f8e4..e9cb1a57cb75 100644
--- a/drivers/mmc/host/sunplus-mmc.c
+++ b/drivers/mmc/host/sunplus-mmc.c
@@ -885,7 +885,7 @@ static int spmmc_drv_probe(struct platform_device *pdev)
return dev_err_probe(&pdev->dev, PTR_ERR(host->rstc), "rst get fail\n");

host->irq = platform_get_irq(pdev, 0);
- if (host->irq <= 0)
+ if (host->irq < 0)
return host->irq;

ret = devm_request_threaded_irq(&pdev->dev, host->irq,
--
2.39.3



2023-08-09 12:51:22

by Dan Carpenter

[permalink] [raw]
Subject: Re: [PATCH next v2 2/2] mmc: sunplus: Fix platform_get_irq() error checking

On Wed, Aug 09, 2023 at 01:33:51PM +0200, Ulf Hansson wrote:
> On Wed, 9 Aug 2023 at 09:19, Harshit Mogalapalli
> <[email protected]> wrote:
> >
> > The platform_get_irq() function returns negative error codes on failure.
> >
> > Fixes: 4e268fed8b18 ("mmc: Add mmc driver for Sunplus SP7021")
> > Reported-by: Dan Carpenter <[email protected]>
> > Closes: https://lore.kernel.org/all/[email protected]/
> > Signed-off-by: Harshit Mogalapalli <[email protected]>
>
> Applied for fixes and by adding a stable tag, thanks!

It's not really a fix. The platform_get_irq() function can't actually
return zero.

I asked Arnd about this and he said that there were some arches where
zero was a valid IRQ but they're not in the upstream kernel any more and
we're hopefully not going to do that again.

regards,
dan carpenter


2023-08-09 13:00:01

by Ulf Hansson

[permalink] [raw]
Subject: Re: [PATCH next v2 2/2] mmc: sunplus: Fix platform_get_irq() error checking

On Wed, 9 Aug 2023 at 09:19, Harshit Mogalapalli
<[email protected]> wrote:
>
> The platform_get_irq() function returns negative error codes on failure.
>
> Fixes: 4e268fed8b18 ("mmc: Add mmc driver for Sunplus SP7021")
> Reported-by: Dan Carpenter <[email protected]>
> Closes: https://lore.kernel.org/all/[email protected]/
> Signed-off-by: Harshit Mogalapalli <[email protected]>

Applied for fixes and by adding a stable tag, thanks!

Kind regards
Uffe


> ---
> v1->v2: Split into two patches as they are doing different things.
>
> This is based on static analysis with smatch, only compile tested.
> ---
> drivers/mmc/host/sunplus-mmc.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/mmc/host/sunplus-mmc.c b/drivers/mmc/host/sunplus-mmc.c
> index 2bdebeb1f8e4..e9cb1a57cb75 100644
> --- a/drivers/mmc/host/sunplus-mmc.c
> +++ b/drivers/mmc/host/sunplus-mmc.c
> @@ -885,7 +885,7 @@ static int spmmc_drv_probe(struct platform_device *pdev)
> return dev_err_probe(&pdev->dev, PTR_ERR(host->rstc), "rst get fail\n");
>
> host->irq = platform_get_irq(pdev, 0);
> - if (host->irq <= 0)
> + if (host->irq < 0)
> return host->irq;
>
> ret = devm_request_threaded_irq(&pdev->dev, host->irq,
> --
> 2.39.3
>

2023-08-09 15:07:34

by Ulf Hansson

[permalink] [raw]
Subject: Re: [PATCH next v2 2/2] mmc: sunplus: Fix platform_get_irq() error checking

On Wed, 9 Aug 2023 at 13:51, Dan Carpenter <[email protected]> wrote:
>
> On Wed, Aug 09, 2023 at 01:33:51PM +0200, Ulf Hansson wrote:
> > On Wed, 9 Aug 2023 at 09:19, Harshit Mogalapalli
> > <[email protected]> wrote:
> > >
> > > The platform_get_irq() function returns negative error codes on failure.
> > >
> > > Fixes: 4e268fed8b18 ("mmc: Add mmc driver for Sunplus SP7021")
> > > Reported-by: Dan Carpenter <[email protected]>
> > > Closes: https://lore.kernel.org/all/[email protected]/
> > > Signed-off-by: Harshit Mogalapalli <[email protected]>
> >
> > Applied for fixes and by adding a stable tag, thanks!
>
> It's not really a fix. The platform_get_irq() function can't actually
> return zero.
>
> I asked Arnd about this and he said that there were some arches where
> zero was a valid IRQ but they're not in the upstream kernel any more and
> we're hopefully not going to do that again.

Alright, I moved this to the next branch and dropped the fixes and stable tags.

Kind regards
Uffe