Skip to contentSkip to conversation

bcmgenet: add WOL IRQ check

PATCH Applied Sergey Shtylyov 4 participants 7 messages Jan 13, 2022 – Jan 14, 2022

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

PATCH 1/1 bcmgenet: add WOL IRQ check

The driver neglects to check the result of platform_get_irq_optional()'s call and blithely passes the negative error codes to devm_request_irq() (which takes *unsigned* IRQ #), causing it to fail with -EINVAL. Stop calling devm_request_irq() with the invalid IRQ #s.

---
This patch is against DaveM's 'net.git' repo.

 drivers/net/ethernet/broadcom/genet/bcmgenet.c |   10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
drivers/net/ethernet/broadcom/genet/bcmgenet.c +6 -4
Index: net/drivers/net/ethernet/broadcom/genet/bcmgenet.c
===================================================================
@@ -4020,10 +4020,12 @@ static int bcmgenet_probe(struct platfor
 
 	/* Request the WOL interrupt and advertise suspend if available */
 	priv->wol_irq_disabled = true;
-	err = devm_request_irq(&pdev->dev, priv->wol_irq, bcmgenet_wol_isr, 0,
-			       dev->name, priv);
-	if (!err)
-		device_set_wakeup_capable(&pdev->dev, 1);
+	if (priv->wol_irq > 0) {
+		err = devm_request_irq(&pdev->dev, priv->wol_irq,
+				       bcmgenet_wol_isr, 0, dev->name, priv);
+		if (!err)
+			device_set_wakeup_capable(&pdev->dev, 1);
+	}
 
 	/* Set the needed headroom to account for any possible
 	 * features enabling/disabling at runtime
#1 lore raw
Quoted 9 lines · Sergey Shtylyov

The driver neglects to check the result of platform_get_irq_optional()'s call and blithely passes the negative error codes to devm_request_irq() (which takes *unsigned* IRQ #), causing it to fail with -EINVAL. Stop calling devm_request_irq() with the invalid IRQ #s.

---
This patch is against DaveM's 'net.git' repo.

Since this is for net, it needs a Fixes: tag.

Fixes 8562056f267d ("net: bcmgenet: request Wake-on-LAN interrupt")

Andrew

#2 lore raw
Quoted 6 lines · Andrew Lunn
Quoted 5 lines · Sergey Shtylyov

The driver neglects to check the result of platform_get_irq_optional()'s call and blithely passes the negative error codes to devm_request_irq() (which takes *unsigned* IRQ #), causing it to fail with -EINVAL. Stop calling devm_request_irq() with the invalid IRQ #s.

Quoted 8 lines
Quoted 4 lines

---
This patch is against DaveM's 'net.git' repo.

Since this is for net, it needs a Fixes: tag.

Fixes 8562056f267d ("net: bcmgenet: request Wake-on-LAN interrupt")

I don't have strong objections whether we want to consider this a bug fix or not, but since the code only acts upon devm_request_irq() returning 0 meaning success, this seems more like an improvement rather than fixing an actual issue.

Signature · 1 line
Florian
#3 lore raw
Quoted 11 lines · Florian Fainelli
Quoted 8 lines · Andrew Lunn
Quoted 7 lines · Sergey Shtylyov

The driver neglects to check the result of platform_get_irq_optional()'s call and blithely passes the negative error codes to devm_request_irq() (which takes *unsigned* IRQ #), causing it to fail with -EINVAL. Stop calling devm_request_irq() with the invalid IRQ #s.

Quoted 8 lines
Quoted 6 lines
Quoted 2 lines

---
This patch is against DaveM's 'net.git' repo.

Since this is for net, it needs a Fixes: tag.

Fixes 8562056f267d ("net: bcmgenet: request Wake-on-LAN interrupt")

I don't have strong objections whether we want to consider this a bug fix or not, but since the code only acts upon devm_request_irq() returning 0 meaning success, this seems more like an improvement rather than fixing an actual issue.

If you do repost, please subject your patch with "net: bcmgenet" for consistency with previous commits done to that file, and feel free to add:

Signature · 1 line
Florian
#4 lore raw
In reply to Florian Fainelli

Hello!

Quoted 7 lines · Florian Fainelli
Quoted 7 lines
Quoted 7 lines

The driver neglects to check the result of platform_get_irq_optional()'s call and blithely passes the negative error codes to devm_request_irq() (which takes *unsigned* IRQ #), causing it to fail with -EINVAL. Stop calling devm_request_irq() with the invalid IRQ #s.

Quoted 8 lines
Quoted 6 lines
Quoted 2 lines

---
This patch is against DaveM's 'net.git' repo.

Since this is for net, it needs a Fixes: tag.

Fixes 8562056f267d ("net: bcmgenet: request Wake-on-LAN interrupt")

I don't have strong objections whether we want to consider this a bug fix or not,

Formally, it's a fix -- as you shouldn't call devm_request_irq() with "negative" IRQ #s.

Quoted 1 line

but since the code only acts upon devm_request_irq() returning 0 meaning success, this seems more like an improvement rather than fixing an actual issue.

More like a cleanup (no, not improvement).

MBR, Sergey

#5 lore raw
In reply to Andrew Lunn

Hello!

Quoted 5 lines · Andrew Lunn
Quoted 5 lines

The driver neglects to check the result of platform_get_irq_optional()'s call and blithely passes the negative error codes to devm_request_irq() (which takes *unsigned* IRQ #), causing it to fail with -EINVAL. Stop calling devm_request_irq() with the invalid IRQ #s.

Quoted 8 lines
Quoted 4 lines

---
This patch is against DaveM's 'net.git' repo.

Since this is for net, it needs a Fixes: tag.

Fixes 8562056f267d ("net: bcmgenet: request Wake-on-LAN interrupt")

Indeed, I completely forgot about it. Thanks! :-)

Quoted 1 line

Andrew

MBR, Sergey

#6 lore raw
In reply to Sergey Shtylyov
This patch was applied to netdev/net.git (master) by David S. Miller <[email protected]>:

Hello:

This patch was applied to netdev/net.git (master)
by David S. Miller <[email protected]>:

Quoted 8 lines · On Thu, 13 Jan 2022 22:46:07 +0300 you wrote:

The driver neglects to check the result of platform_get_irq_optional()'s call and blithely passes the negative error codes to devm_request_irq() (which takes *unsigned* IRQ #), causing it to fail with -EINVAL. Stop calling devm_request_irq() with the invalid IRQ #s.

[...]

Here is the summary with links:
- bcmgenet: add WOL IRQ check

    https://git.kernel.org/netdev/net/c/9deb48b53e7f

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html