Return-Path: Received: from userp1040.oracle.com ([156.151.31.81]:48109 "EHLO userp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753217AbcBJPOu (ORCPT ); Wed, 10 Feb 2016 10:14:50 -0500 From: Sasha Levin To: stable@vger.kernel.org, stable-commits@vger.kernel.org Cc: Mathias Nyman , Greg Kroah-Hartman , Sasha Levin Subject: [added to the 4.1 stable tree] xhci: Fix list corruption in urb dequeue at host removal Date: Wed, 10 Feb 2016 10:12:01 -0500 Message-Id: <1455117136-28870-217-git-send-email-sasha.levin@oracle.com> In-Reply-To: <1455117136-28870-1-git-send-email-sasha.levin@oracle.com> References: <1455117136-28870-1-git-send-email-sasha.levin@oracle.com> Sender: stable-owner@vger.kernel.org List-ID: From: Mathias Nyman This patch has been added to the 4.1 stable tree. If you have any objections, please let us know. =============== [ 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 --- drivers/usb/host/xhci.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c index f6bb118..910f7fa 100644 --- a/drivers/usb/host/xhci.c +++ b/drivers/usb/host/xhci.c @@ -1559,7 +1559,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); -- 2.5.0