Skip to content

Commit da2522d

Browse files
jinliangwkuba-moo
authored andcommitted
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: 0791c03 ("net: mctp: Add MCTP USB transport driver") Signed-off-by: Jinliang Wang <[email protected]> Acked-by: Jeremy Kerr <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 5311023 commit da2522d

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

drivers/net/mctp/mctp-usb.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,11 +96,13 @@ static netdev_tx_t mctp_usb_start_xmit(struct sk_buff *skb,
9696
skb->data, skb->len,
9797
mctp_usb_out_complete, skb);
9898

99+
/* Stops TX queue first to prevent race condition with URB complete */
100+
netif_stop_queue(dev);
99101
rc = usb_submit_urb(urb, GFP_ATOMIC);
100-
if (rc)
102+
if (rc) {
103+
netif_wake_queue(dev);
101104
goto err_drop;
102-
else
103-
netif_stop_queue(dev);
105+
}
104106

105107
return NETDEV_TX_OK;
106108

0 commit comments

Comments
 (0)