Skip to content

Commit bcf42aa

Browse files
matnymangregkh
authored andcommitted
xhci: fix null pointer dereference in stop command timeout function
The stop endpoint command has its own 5 second timeout timer. If the timeout function is triggered between USB3 and USB2 host removal it will try to call usb_hc_died(xhci_to_hcd(xhci)->primary_hcd) the ->primary_hcd will be set to NULL at USB3 hcd removal. Fix this by first checking if the PCI host is being removed, and also by using only xhci_to_hcd() as it will always return the primary hcd. CC: <[email protected]> Signed-off-by: Mathias Nyman <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent c693593 commit bcf42aa

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

drivers/usb/host/xhci-ring.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -850,6 +850,10 @@ void xhci_stop_endpoint_command_watchdog(unsigned long arg)
850850
spin_lock_irqsave(&xhci->lock, flags);
851851

852852
ep->stop_cmds_pending--;
853+
if (xhci->xhc_state & XHCI_STATE_REMOVING) {
854+
spin_unlock_irqrestore(&xhci->lock, flags);
855+
return;
856+
}
853857
if (xhci->xhc_state & XHCI_STATE_DYING) {
854858
xhci_dbg_trace(xhci, trace_xhci_dbg_cancel_urb,
855859
"Stop EP timer ran, but another timer marked "
@@ -903,7 +907,7 @@ void xhci_stop_endpoint_command_watchdog(unsigned long arg)
903907
spin_unlock_irqrestore(&xhci->lock, flags);
904908
xhci_dbg_trace(xhci, trace_xhci_dbg_cancel_urb,
905909
"Calling usb_hc_died()");
906-
usb_hc_died(xhci_to_hcd(xhci)->primary_hcd);
910+
usb_hc_died(xhci_to_hcd(xhci));
907911
xhci_dbg_trace(xhci, trace_xhci_dbg_cancel_urb,
908912
"xHCI host controller is dead.");
909913
}

0 commit comments

Comments
 (0)