xhci: handle port status events for removed USB3 hcd
Subsystems (2)
PATCH 2/6 xhci: handle port status events for removed USB3 hcd
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 <[email protected]>
Reported-by Peter Chen <[email protected]>
Tested-by Jack Pham <[email protected]>
Signed-off-by Mathias Nyman <[email protected]>
--- drivers/usb/host/xhci-ring.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/usb/host/xhci-ring.c +7 -0
@@ -1556,6 +1556,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;