9cf5aa2e990ead2c44042566184c11cb942dfc2a
[openwrt/staging/wigyori.git] /
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
5 xhci_endpoint_reset()
6
7 See https://github.com/raspberrypi/linux/issues/3981
8
9 Two read-modify-write cycles on ep->ep_state are not guarded by
10 xhci->lock. Fix these.
11
12 Signed-off-by: Jonathan Bell <jonathan@raspberrypi.com>
13 ---
14 drivers/usb/host/xhci.c | 5 +++++
15 1 file changed, 5 insertions(+)
16
17 --- a/drivers/usb/host/xhci.c
18 +++ b/drivers/usb/host/xhci.c
19 @@ -3270,10 +3270,13 @@ static void xhci_endpoint_reset(struct u
20 return;
21
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);
27 return;
28 }
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 @@ -3359,8 +3362,10 @@ static void xhci_endpoint_reset(struct u
34 xhci_free_command(xhci, cfg_cmd);
35 cleanup:
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);
41 }
42
43 static int xhci_check_streams_endpoint(struct xhci_hcd *xhci,