Skip to contentSkip to conversation

net: mctp: Fix tx queue stall

PATCH Applied Jinliang Wang 3 participants 3 messages Oct 27, 2025 – Oct 30, 2025

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

PATCH v3 1/1 net: mctp: Fix tx queue stall

The tx queue can become permanently stuck in a stopped state due to a race condition between the URB submission path and its completion callback.

The URB completion callback can run immediately after usb_submit_urb() returns, before the submitting function calls netif_stop_queue(). If this occurs, the queue state management becomes desynchronized, leading to a stall where the queue is never woken.

Fix this by moving the netif_stop_queue() call to before submitting the URB. This closes the race window by ensuring the network stack is aware the queue is stopped before the URB completion can possibly run.

Fixes 0791c0327a6e ("net: mctp: Add MCTP USB transport driver")

---
v3:
- target net tree, add fixes tag

v2:
- remove duplicate comment in commit message

---
 drivers/net/mctp/mctp-usb.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/net/mctp/mctp-usb.c +5 -3
index 36ccc53b1797..ef860cfc629f 100644
@@ -96,11 +96,13 @@ static netdev_tx_t mctp_usb_start_xmit(struct sk_buff *skb,
 			  skb->data, skb->len,
 			  mctp_usb_out_complete, skb);
 
+	/* Stops TX queue first to prevent race condition with URB complete */
+	netif_stop_queue(dev);
 	rc = usb_submit_urb(urb, GFP_ATOMIC);
-	if (rc)
+	if (rc) {
+		netif_wake_queue(dev);
 		goto err_drop;
-	else
-		netif_stop_queue(dev);
+	}
 
 	return NETDEV_TX_OK;
 
Signature · 1 line
2.51.1.821.gb6fe4d2222-goog
maintainer Acked-by on v3 1/1
#1 lore raw

Hi Jinliang,

Quoted 4 lines

The tx queue can become permanently stuck in a stopped state due to a race condition between the URB submission path and its completion callback.

Quoted 8 lines

The URB completion callback can run immediately after usb_submit_urb() returns, before the submitting function calls netif_stop_queue(). If this occurs, the queue state management becomes desynchronized, leading to a stall where the queue is never woken.

Fix this by moving the netif_stop_queue() call to before submitting the URB. This closes the race window by ensuring the network stack is aware the queue is stopped before the URB completion can possibly run.

Thanks!

Cheers,

Jeremy

#2 lore raw
In reply to Jinliang Wang
This patch was applied to netdev/net.git (main) by Jakub Kicinski <[email protected]>:

Hello:

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

Quoted 10 lines · On Sun, 26 Oct 2025 23:55:30 -0700 you wrote:

The tx queue can become permanently stuck in a stopped state due to a race condition between the URB submission path and its completion callback.

The URB completion callback can run immediately after usb_submit_urb() returns, before the submitting function calls netif_stop_queue(). If this occurs, the queue state management becomes desynchronized, leading to a stall where the queue is never woken.

[...]

Here is the summary with links:
- [net,v3] net: mctp: Fix tx queue stall

    https://git.kernel.org/netdev/net/c/da2522df3fcc

You are awesome, thank you!

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