Skip to content

Commit 5c82171

Browse files
matnymangregkh
authored andcommitted
xhci: Fix list corruption in urb dequeue at host removal
xhci driver frees data for all devices, both usb2 and and usb3 the first time usb_remove_hcd() is called, including td_list and and xhci_ring structures. When usb_remove_hcd() is called a second time for the second xhci bus it will try to dequeue all pending urbs, and touches td_list which is already freed for that endpoint. Cc: <[email protected]> Reported-by: Joe Lawrence <[email protected]> Tested-by: Joe Lawrence <[email protected]> Signed-off-by: Mathias Nyman <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 2ad294d commit 5c82171

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

drivers/usb/host/xhci.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1554,7 +1554,9 @@ int xhci_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status)
15541554
xhci_dbg_trace(xhci, trace_xhci_dbg_cancel_urb,
15551555
"HW died, freeing TD.");
15561556
urb_priv = urb->hcpriv;
1557-
for (i = urb_priv->td_cnt; i < urb_priv->length; i++) {
1557+
for (i = urb_priv->td_cnt;
1558+
i < urb_priv->length && xhci->devs[urb->dev->slot_id];
1559+
i++) {
15581560
td = urb_priv->td[i];
15591561
if (!list_empty(&td->td_list))
15601562
list_del_init(&td->td_list);

0 commit comments

Comments
 (0)