net: usb: lan78xx: fix error handling in lan78xx_open()
Subsystems (5)
PATCH v3 1/1 net: usb: lan78xx: fix error handling in lan78xx_open()
A failed interrupt URB submission leaves NAPI enabled and EVENT_DEV_OPEN set. A subsequent open enables NAPI again, triggering BUG_ON() in napi_enable().
Clear EVENT_DEV_OPEN and disable NAPI on the submission error path.
Reproduced using failslab on a Raspberry Pi 3 Model B+ (LAN7515). With the fix, the injected allocation failure returns -ENOMEM and a subsequent open succeeds. Verified connectivity with ping and SSH.
---
v3:
- Target net-next and drop the Fixes tag as requested by Andrew.
v2: https://lore.kernel.org/netdev/[email protected]
- Move cleanup code to err_napi unwind label as suggested by Nicolai.
- Add Nicolai's Reviewed-by tag.
v1: https://lore.kernel.org/netdev/[email protected]
--- drivers/net/usb/lan78xx.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-)
drivers/net/usb/lan78xx.c +8 -5
@@ -3497,17 +3497,20 @@ static int lan78xx_open(struct net_device *net)if (ret <0 ) {netif_err (dev, ifup, dev->net,"intr submit %d\n" , ret); - goto done; + goto err_napi; } }phylink_start (dev->phylink); - -done:mutex_unlock (&dev->dev_mutex); -if (ret <0 ) -usb_autopm_put_interface (dev->intf); +return 0 ; + +err_napi: +clear_bit (EVENT_DEV_OPEN , &dev->flags); +napi_disable (&dev->napi); +mutex_unlock (&dev->dev_mutex); +usb_autopm_put_interface (dev->intf);return ret; }
Signature · 1 line
2.55.0
This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Quoted 11 lines · On Mon, 2 Nov 2026 22:11:19 +0100 you wrote:
A failed interrupt URB submission leaves NAPI enabled and
EVENT_DEV_OPENset. A subsequent open enables NAPI again, triggeringBUG_ON()innapi_enable().Clear
EVENT_DEV_OPENand disable NAPI on the submission error path.Reproduced using failslab on a Raspberry Pi 3 Model B+ (LAN7515). With the fix, the injected allocation failure returns
-ENOMEMand a subsequent open succeeds. Verified connectivity with ping and SSH.[...]
Here is the summary with links:
- [net-next,v3] net: usb: lan78xx: fix error handling in lan78xx_open()
https://git.kernel.org/netdev/net-next/c/1134247a3ae5
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html