From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga01.intel.com ([192.55.52.88]:36888 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727522AbeI0Wmi (ORCPT ); Thu, 27 Sep 2018 18:42:38 -0400 From: Mathias Nyman To: jackp@codeaurora.org Cc: peter.chen@nxp.com, linux-imx@nxp.com, linux-usb@vger.kernel.org, jun.li@nxp.com, joel@jms.id.au, mrana@codeaurora.org, Mathias Nyman , stable@vger.kernel.org Subject: [RFT PATCH 2/2] xhci: handle port status events for removed USB3 hcd Date: Thu, 27 Sep 2018 19:26:27 +0300 Message-Id: <1538065587-22997-2-git-send-email-mathias.nyman@linux.intel.com> In-Reply-To: <1538065587-22997-1-git-send-email-mathias.nyman@linux.intel.com> References: <20180927013948.GB17520@jackp-linux.qualcomm.com> <1538065587-22997-1-git-send-email-mathias.nyman@linux.intel.com> Sender: stable-owner@vger.kernel.org List-ID: At xhci removal the USB3 hcd (shared_hcd) is removed before the primary USB2 hcd. Interrupts for port status changes may still occur for USB3 ports after the shared_hcd is freed, causing NULL pointer dereference. Check if xhci->shared_hcd is still valid before handing USB3 port events Cc: Reported-by: Peter Chen Signed-off-by: Mathias Nyman --- drivers/usb/host/xhci-ring.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c index f0a99aa..3d314b8 100644 --- a/drivers/usb/host/xhci-ring.c +++ b/drivers/usb/host/xhci-ring.c @@ -1552,6 +1552,13 @@ static void handle_port_status(struct xhci_hcd *xhci, goto cleanup; } + /* We might get interrupts after shared_hcd is removed */ + if (port->rhub == &xhci->usb3_rhub && xhci->shared_hcd == NULL) { + xhci_dbg(xhci, "ignore port event for removed USB3 hcd\n"); + bogus_port_status = true; + goto cleanup; + } + hcd = port->rhub->hcd; bus_state = &xhci->bus_state[hcd_index(hcd)]; hcd_portnum = port->hcd_portnum; -- 2.7.4