From: Mathias Nyman Date: Tue, 26 Jan 2016 15:50:12 +0000 (+0200) Subject: xhci: Fix list corruption in urb dequeue at host removal X-Git-Tag: v4.1.12-92~150^2~240 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=1869c9329f2de2813d7c46c23db50e4b89f9e7e9;p=users%2Fjedix%2Flinux-maple.git xhci: Fix list corruption in urb dequeue at host removal Orabug: 23330812 [ Upstream commit 5c82171167adb8e4ac77b91a42cd49fb211a81a0 ] 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: Reported-by: Joe Lawrence Tested-by: Joe Lawrence Signed-off-by: Mathias Nyman Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin (cherry picked from commit 8552bea30320cc866c7fb5d9a687c3e6d15fb5c1) Signed-off-by: Dan Duval --- diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c index 26f62b2b33f8..f7fd43143d0e 100644 --- a/drivers/usb/host/xhci.c +++ b/drivers/usb/host/xhci.c @@ -1549,7 +1549,9 @@ int xhci_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status) xhci_dbg_trace(xhci, trace_xhci_dbg_cancel_urb, "HW died, freeing TD."); urb_priv = urb->hcpriv; - for (i = urb_priv->td_cnt; i < urb_priv->length; i++) { + for (i = urb_priv->td_cnt; + i < urb_priv->length && xhci->devs[urb->dev->slot_id]; + i++) { td = urb_priv->td[i]; if (!list_empty(&td->td_list)) list_del_init(&td->td_list);