From: Mathias Nyman <mathias.nyman@linux.intel.com>
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 <mathias.nyman@linux.intel.com>,
stable@vger.kernel.org
Subject: [RFT,2/2] xhci: handle port status events for removed USB3 hcd
Date: Thu, 27 Sep 2018 19:26:27 +0300 [thread overview]
Message-ID: <1538065587-22997-2-git-send-email-mathias.nyman@linux.intel.com> (raw)
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: <stable@vger.kernel.org>
Reported-by: Peter Chen <peter.chen@nxp.com>
Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
---
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;
WARNING: multiple messages have this Message-ID (diff)
From: Mathias Nyman <mathias.nyman@linux.intel.com>
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 <mathias.nyman@linux.intel.com>,
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 [thread overview]
Message-ID: <1538065587-22997-2-git-send-email-mathias.nyman@linux.intel.com> (raw)
In-Reply-To: <1538065587-22997-1-git-send-email-mathias.nyman@linux.intel.com>
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: <stable@vger.kernel.org>
Reported-by: Peter Chen <peter.chen@nxp.com>
Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
---
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
next reply other threads:[~2018-09-27 16:26 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-09-27 16:26 Mathias Nyman [this message]
2018-09-27 16:26 ` [RFT PATCH 2/2] xhci: handle port status events for removed USB3 hcd Mathias Nyman
-- strict thread matches above, loose matches on Subject: below --
2018-10-01 15:52 [RFT,2/2] " Mathias Nyman
2018-10-01 15:52 ` [RFT PATCH 2/2] " Mathias Nyman
2018-09-28 18:12 [RFT,1/2] xhci: Fix leaking USB3 shared_hcd at xhci removal Jack Pham
2018-09-28 18:12 ` [RFT PATCH 1/2] " Jack Pham
2018-09-28 18:10 [RFT,2/2] xhci: handle port status events for removed USB3 hcd Jack Pham
2018-09-28 18:10 ` [RFT PATCH 2/2] " Jack Pham
2018-09-28 3:35 [RFT,1/2] xhci: Fix leaking USB3 shared_hcd at xhci removal Peter Chen
2018-09-28 3:35 ` [RFT PATCH 1/2] " Peter Chen
2018-09-28 3:35 [RFT,2/2] xhci: handle port status events for removed USB3 hcd Peter Chen
2018-09-28 3:35 ` [RFT PATCH 2/2] " Peter Chen
2018-09-28 2:16 [RFT,1/2] xhci: Fix leaking USB3 shared_hcd at xhci removal Chunfeng Yun
2018-09-28 2:16 ` [RFT PATCH 1/2] " Chunfeng Yun
2018-09-27 16:34 [RFT,2/2] xhci: handle port status events for removed USB3 hcd Mathias Nyman
2018-09-27 16:34 ` [RFT PATCH 2/2] " Mathias Nyman
2018-09-27 16:26 [RFT,1/2] xhci: Fix leaking USB3 shared_hcd at xhci removal Mathias Nyman
2018-09-27 16:26 ` [RFT PATCH 1/2] " Mathias Nyman
2018-09-27 1:39 [1/3] usb: host: xhci: fix oops when removing hcd Jack Pham
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1538065587-22997-2-git-send-email-mathias.nyman@linux.intel.com \
--to=mathias.nyman@linux.intel.com \
--cc=jackp@codeaurora.org \
--cc=joel@jms.id.au \
--cc=jun.li@nxp.com \
--cc=linux-imx@nxp.com \
--cc=linux-usb@vger.kernel.org \
--cc=mrana@codeaurora.org \
--cc=peter.chen@nxp.com \
--cc=stable@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.