Skip to content

Commit cd04fbf

Browse files
P33Mpelwell
authored andcommitted
xhci: guard accesses to ep_state in xhci_endpoint_reset()
See raspberrypi#3981 Two read-modify-write cycles on ep->ep_state are not guarded by xhci->lock. Fix these. Signed-off-by: Jonathan Bell <jonathan@raspberrypi.com>
1 parent 35c6650 commit cd04fbf

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

‎drivers/usb/host/xhci.c‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3269,10 +3269,13 @@ static void xhci_endpoint_reset(struct usb_hcd *hcd,
32693269
return;
32703270

32713271
/* Bail out if toggle is already being cleared by a endpoint reset */
3272+
spin_lock_irqsave(&xhci->lock, flags);
32723273
if (ep->ep_state & EP_HARD_CLEAR_TOGGLE) {
32733274
ep->ep_state &= ~EP_HARD_CLEAR_TOGGLE;
3275+
spin_unlock_irqrestore(&xhci->lock, flags);
32743276
return;
32753277
}
3278+
spin_unlock_irqrestore(&xhci->lock, flags);
32763279
/* Only interrupt and bulk ep's use data toggle, USB2 spec 5.5.4-> */
32773280
if (usb_endpoint_xfer_control(&host_ep->desc) ||
32783281
usb_endpoint_xfer_isoc(&host_ep->desc))
@@ -3358,8 +3361,10 @@ static void xhci_endpoint_reset(struct usb_hcd *hcd,
33583361
xhci_free_command(xhci, cfg_cmd);
33593362
cleanup:
33603363
xhci_free_command(xhci, stop_cmd);
3364+
spin_lock_irqsave(&xhci->lock, flags);
33613365
if (ep->ep_state & EP_SOFT_CLEAR_TOGGLE)
33623366
ep->ep_state &= ~EP_SOFT_CLEAR_TOGGLE;
3367+
spin_unlock_irqrestore(&xhci->lock, flags);
33633368
}
33643369

33653370
static int xhci_check_streams_endpoint(struct xhci_hcd *xhci,

0 commit comments

Comments
 (0)