1 From 9d51ba9909129465493d56a7134ce4220d2e69e9 Mon Sep 17 00:00:00 2001
2 From: Jonathan Bell <jonathan@raspberrypi.com>
3 Date: Mon, 16 Aug 2021 14:43:06 +0100
4 Subject: [PATCH] xhci: guard accesses to ep_state in
7 See https://github.com/raspberrypi/linux/issues/3981
9 Two read-modify-write cycles on ep->ep_state are not guarded by
10 xhci->lock. Fix these.
12 Signed-off-by: Jonathan Bell <jonathan@raspberrypi.com>
14 drivers/usb/host/xhci.c | 5 +++++
15 1 file changed, 5 insertions(+)
17 --- a/drivers/usb/host/xhci.c
18 +++ b/drivers/usb/host/xhci.c
19 @@ -3269,10 +3269,13 @@ static void xhci_endpoint_reset(struct u
22 /* Bail out if toggle is already being cleared by a endpoint reset */
23 + spin_lock_irqsave(&xhci->lock, flags);
24 if (ep->ep_state & EP_HARD_CLEAR_TOGGLE) {
25 ep->ep_state &= ~EP_HARD_CLEAR_TOGGLE;
26 + spin_unlock_irqrestore(&xhci->lock, flags);
29 + spin_unlock_irqrestore(&xhci->lock, flags);
30 /* Only interrupt and bulk ep's use data toggle, USB2 spec 5.5.4-> */
31 if (usb_endpoint_xfer_control(&host_ep->desc) ||
32 usb_endpoint_xfer_isoc(&host_ep->desc))
33 @@ -3358,8 +3361,10 @@ static void xhci_endpoint_reset(struct u
34 xhci_free_command(xhci, cfg_cmd);
36 xhci_free_command(xhci, stop_cmd);
37 + spin_lock_irqsave(&xhci->lock, flags);
38 if (ep->ep_state & EP_SOFT_CLEAR_TOGGLE)
39 ep->ep_state &= ~EP_SOFT_CLEAR_TOGGLE;
40 + spin_unlock_irqrestore(&xhci->lock, flags);
43 static int xhci_check_streams_endpoint(struct xhci_hcd *xhci,