* [PATCH 1/1] net: bcmgenet: fix incorrect return value checks
@ 2017-04-23 10:01 Pan Bian
2017-04-24 19:48 ` David Miller
0 siblings, 1 reply; 3+ messages in thread
From: Pan Bian @ 2017-04-23 10:01 UTC (permalink / raw)
To: Florian Fainelli, netdev; +Cc: linux-kernel, Pan Bian
From: Pan Bian <bianpan2016@163.com>
Function platform_get_irq() will return a negative value on errors.
However, in function bcmgenet_probe(), 0 is considered as a flag of
error. This patch fixes the bug by checking whether the return value of
platform_get_irq() is less than 0.
Signed-off-by: Pan Bian <bianpan2016@163.com>
---
drivers/net/ethernet/broadcom/genet/bcmgenet.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/broadcom/genet/bcmgenet.c b/drivers/net/ethernet/broadcom/genet/bcmgenet.c
index 365895e..0bccf2b 100644
--- a/drivers/net/ethernet/broadcom/genet/bcmgenet.c
+++ b/drivers/net/ethernet/broadcom/genet/bcmgenet.c
@@ -3329,7 +3329,7 @@ static int bcmgenet_probe(struct platform_device *pdev)
priv->irq0 = platform_get_irq(pdev, 0);
priv->irq1 = platform_get_irq(pdev, 1);
priv->wol_irq = platform_get_irq(pdev, 2);
- if (!priv->irq0 || !priv->irq1) {
+ if (priv->irq0 < 0 || priv->irq1 < 0) {
dev_err(&pdev->dev, "can't find IRQs\n");
err = -EINVAL;
goto err;
--
1.9.1
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH 1/1] net: bcmgenet: fix incorrect return value checks
2017-04-23 10:01 [PATCH 1/1] net: bcmgenet: fix incorrect return value checks Pan Bian
@ 2017-04-24 19:48 ` David Miller
2017-04-24 19:52 ` Florian Fainelli
0 siblings, 1 reply; 3+ messages in thread
From: David Miller @ 2017-04-24 19:48 UTC (permalink / raw)
To: bianpan201602; +Cc: f.fainelli, netdev, linux-kernel, bianpan2016
From: Pan Bian <bianpan201602@163.com>
Date: Sun, 23 Apr 2017 18:01:05 +0800
> From: Pan Bian <bianpan2016@163.com>
>
> Function platform_get_irq() will return a negative value on errors.
> However, in function bcmgenet_probe(), 0 is considered as a flag of
> error. This patch fixes the bug by checking whether the return value of
> platform_get_irq() is less than 0.
>
> Signed-off-by: Pan Bian <bianpan2016@163.com>
I'm definitely not confident enough to apply this.
On some platform zero IRQs are invalid.
There are also lots of pieces of code that check the return value ">
0" as success.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH 1/1] net: bcmgenet: fix incorrect return value checks
2017-04-24 19:48 ` David Miller
@ 2017-04-24 19:52 ` Florian Fainelli
0 siblings, 0 replies; 3+ messages in thread
From: Florian Fainelli @ 2017-04-24 19:52 UTC (permalink / raw)
To: David Miller, bianpan201602; +Cc: netdev, linux-kernel, bianpan2016
On 04/24/2017 12:48 PM, David Miller wrote:
> From: Pan Bian <bianpan201602@163.com>
> Date: Sun, 23 Apr 2017 18:01:05 +0800
>
>> From: Pan Bian <bianpan2016@163.com>
>>
>> Function platform_get_irq() will return a negative value on errors.
>> However, in function bcmgenet_probe(), 0 is considered as a flag of
>> error. This patch fixes the bug by checking whether the return value of
>> platform_get_irq() is less than 0.
>>
>> Signed-off-by: Pan Bian <bianpan2016@163.com>
>
> I'm definitely not confident enough to apply this.
>
> On some platform zero IRQs are invalid.
>
> There are also lots of pieces of code that check the return value ">
> 0" as success.
>
I don't think we are fixing any real issue by applying this patch, but I
will do a check on ARM, ARM64 and MIPS where this driver is used to see
if it is even remotely possible to have a 0 IRQ.
--
Florian
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2017-04-24 19:52 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-04-23 10:01 [PATCH 1/1] net: bcmgenet: fix incorrect return value checks Pan Bian
2017-04-24 19:48 ` David Miller
2017-04-24 19:52 ` Florian Fainelli
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).