Skip to content

Commit

Permalink
usb: gadget: u_ether: synchronize with transmit when stopping queue
Browse files Browse the repository at this point in the history
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 <jeff.westfahl@ni.com>
Tested-by: Jaeden Amero <jaeden.amero@ni.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
  • Loading branch information
Jeff Westfahl authored and Felipe Balbi committed Jun 19, 2014
1 parent 02dae36 commit a923207
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions drivers/usb/gadget/u_ether.c
Original file line number Diff line number Diff line change
Expand Up @@ -1120,7 +1120,10 @@ void gether_disconnect(struct gether *link)

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

netif_tx_lock(dev->net);
netif_stop_queue(dev->net);
netif_tx_unlock(dev->net);

netif_carrier_off(dev->net);

/* disable endpoints, forcing (synchronous) completion
Expand Down

0 comments on commit a923207

Please sign in to comment.