Skip to contentSkip to conversation

net: usb: lan78xx: Fix URB reference leak in lan78xx_submit_deferred_urbs()

PATCH Applied Wentao Liang 2 participants 2 messages Sep 17 – Sep 22

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

PATCH 1/1 net: usb: lan78xx: Fix URB reference leak in lan78xx_submit_deferred_urbs()

usb_get_from_anchor() hands over a reference to the URB, which the caller must release. lan78xx_submit_deferred_urbs() never does, so every deferred Tx URB keeps an extra reference: the counter grows on each suspend/resume cycle and the URBs are never freed when the buffers are released. Drop the reference after submitting, and on the path that drops the packet instead of submitting it.

Fixes 5f4cc6e25148 ("lan78xx: Fix race conditions in suspend/resume handling")
---
 drivers/net/usb/lan78xx.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/net/usb/lan78xx.c +2 -0
index bcf293ea1bd3..8e075a31d97c 100644
@@ -5204,10 +5204,12 @@ static bool lan78xx_submit_deferred_urbs(struct lan78xx_net *dev)
 		    !netif_carrier_ok(dev->net) ||
 		    pipe_halted) {
 			lan78xx_release_tx_buf(dev, skb);
+			usb_put_urb(urb);
 			continue;
 		}
 
 		ret = usb_submit_urb(urb, GFP_ATOMIC);
+		usb_put_urb(urb);
 
 		if (ret == 0) {
 			netif_trans_update(dev->net);
Signature · 1 line
2.34.1
#1 lore raw
This patch was applied to netdev/net.git (main) by Paolo Abeni <[email protected]>:

Hello:

This patch was applied to netdev/net.git (main)
by Paolo Abeni <[email protected]>:

Quoted 8 lines · On Thu, 17 Sep 2026 11:58:11 +0000 you wrote:

usb_get_from_anchor() hands over a reference to the URB, which the caller must release. lan78xx_submit_deferred_urbs() never does, so every deferred Tx URB keeps an extra reference: the counter grows on each suspend/resume cycle and the URBs are never freed when the buffers are released. Drop the reference after submitting, and on the path that drops the packet instead of submitting it.

[...]

Here is the summary with links:
- net: usb: lan78xx: Fix URB reference leak in lan78xx_submit_deferred_urbs()

    https://git.kernel.org/netdev/net/c/17741334d00b

You are awesome, thank you!

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