Skip to content

Commit 8552bea

Browse files
matnymansashalevin
authored andcommitted
xhci: Fix list corruption in urb dequeue at host removal
[ Upstream commit 5c82171 ] 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]> Signed-off-by: Sasha Levin <[email protected]>
1 parent 4c54b01 commit 8552bea

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
@@ -1559,7 +1559,9 @@ int xhci_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status)
15591559
xhci_dbg_trace(xhci, trace_xhci_dbg_cancel_urb,
15601560
"HW died, freeing TD.");
15611561
urb_priv = urb->hcpriv;
1562-
for (i = urb_priv->td_cnt; i < urb_priv->length; i++) {
1562+
for (i = urb_priv->td_cnt;
1563+
i < urb_priv->length && xhci->devs[urb->dev->slot_id];
1564+
i++) {
15631565
td = urb_priv->td[i];
15641566
if (!list_empty(&td->td_list))
15651567
list_del_init(&td->td_list);

0 commit comments

Comments
 (0)