2020-10-31 03:15:06

by Yue Haibing

[permalink] [raw]
Subject: [PATCH] sfp: Fix error handing in sfp_probe()

gpiod_to_irq() never return 0, but returns negative in
case of error, check it and set gpio_irq to 0.

Fixes: 73970055450e ("sfp: add SFP module support")
Signed-off-by: YueHaibing <[email protected]>
---
drivers/net/phy/sfp.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/net/phy/sfp.c b/drivers/net/phy/sfp.c
index 1d18c10e8f82..34aa196b7465 100644
--- a/drivers/net/phy/sfp.c
+++ b/drivers/net/phy/sfp.c
@@ -2389,7 +2389,8 @@ static int sfp_probe(struct platform_device *pdev)
continue;

sfp->gpio_irq[i] = gpiod_to_irq(sfp->gpio[i]);
- if (!sfp->gpio_irq[i]) {
+ if (sfp->gpio_irq[i] < 0) {
+ sfp->gpio_irq[i] = 0;
sfp->need_poll = true;
continue;
}
--
2.17.1


2020-10-31 19:00:56

by Andrew Lunn

[permalink] [raw]
Subject: Re: [PATCH] sfp: Fix error handing in sfp_probe()

On Sat, Oct 31, 2020 at 11:10:53AM +0800, YueHaibing wrote:
> gpiod_to_irq() never return 0, but returns negative in
> case of error, check it and set gpio_irq to 0.
>
> Fixes: 73970055450e ("sfp: add SFP module support")
> Signed-off-by: YueHaibing <[email protected]>

Reviewed-by: Andrew Lunn <[email protected]>

Andrew

2020-11-03 01:25:54

by Jakub Kicinski

[permalink] [raw]
Subject: Re: [PATCH] sfp: Fix error handing in sfp_probe()

On Sat, 31 Oct 2020 19:56:05 +0100 Andrew Lunn wrote:
> On Sat, Oct 31, 2020 at 11:10:53AM +0800, YueHaibing wrote:
> > gpiod_to_irq() never return 0, but returns negative in
> > case of error, check it and set gpio_irq to 0.
> >
> > Fixes: 73970055450e ("sfp: add SFP module support")
> > Signed-off-by: YueHaibing <[email protected]>
>
> Reviewed-by: Andrew Lunn <[email protected]>

Applied, thanks!