Skip to content

Commit a923207

Browse files
Jeff WestfahlFelipe Balbi
Jeff Westfahl
authored and
Felipe Balbi
committed
usb: gadget: u_ether: synchronize with transmit when stopping queue
When disconnecting, it's possible that another thread has already made it into eth_start_xmit before we call netif_stop_queue. This can lead to a crash as eth_start_xmit tries to use resources that gether_disconnect is freeing. Use netif_tx_lock/unlock around netif_stop_queue to ensure no threads are executing during the remainder of gether_disconnect. Signed-off-by: Jeff Westfahl <[email protected]> Tested-by: Jaeden Amero <[email protected]> Signed-off-by: Felipe Balbi <[email protected]>
1 parent 02dae36 commit a923207

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

drivers/usb/gadget/u_ether.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1120,7 +1120,10 @@ void gether_disconnect(struct gether *link)
11201120

11211121
DBG(dev, "%s\n", __func__);
11221122

1123+
netif_tx_lock(dev->net);
11231124
netif_stop_queue(dev->net);
1125+
netif_tx_unlock(dev->net);
1126+
11241127
netif_carrier_off(dev->net);
11251128

11261129
/* disable endpoints, forcing (synchronous) completion

0 commit comments

Comments
 (0)