Skip to content

Commit bd82873

Browse files
matnymangregkh
authored andcommitted
xhci: make sure interrupts are restored to correct state
spin_unlock_irqrestore() might be called with stale flags after reading port status, possibly restoring interrupts to a incorrect state. If a usb2 port just finished resuming while the port status is read the spin lock will be temporary released and re-acquired in a separate function. The flags parameter is passed as value instead of a pointer, not updating flags properly before the final spin_unlock_irqrestore() is called. Cc: <[email protected]> # v3.12+ Fixes: 8b3d457 ("usb: Fix xHCI host issues on remote wakeup.") Signed-off-by: Mathias Nyman <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 7ff1116 commit bd82873

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

drivers/usb/host/xhci-hub.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -806,7 +806,7 @@ static void xhci_del_comp_mod_timer(struct xhci_hcd *xhci, u32 status,
806806

807807
static int xhci_handle_usb2_port_link_resume(struct xhci_port *port,
808808
u32 *status, u32 portsc,
809-
unsigned long flags)
809+
unsigned long *flags)
810810
{
811811
struct xhci_bus_state *bus_state;
812812
struct xhci_hcd *xhci;
@@ -860,11 +860,11 @@ static int xhci_handle_usb2_port_link_resume(struct xhci_port *port,
860860
xhci_test_and_clear_bit(xhci, port, PORT_PLC);
861861
xhci_set_link_state(xhci, port, XDEV_U0);
862862

863-
spin_unlock_irqrestore(&xhci->lock, flags);
863+
spin_unlock_irqrestore(&xhci->lock, *flags);
864864
time_left = wait_for_completion_timeout(
865865
&bus_state->rexit_done[wIndex],
866866
msecs_to_jiffies(XHCI_MAX_REXIT_TIMEOUT_MS));
867-
spin_lock_irqsave(&xhci->lock, flags);
867+
spin_lock_irqsave(&xhci->lock, *flags);
868868

869869
if (time_left) {
870870
slot_id = xhci_find_slot_id_by_port(hcd, xhci,
@@ -967,7 +967,7 @@ static void xhci_get_usb3_port_status(struct xhci_port *port, u32 *status,
967967
}
968968

969969
static void xhci_get_usb2_port_status(struct xhci_port *port, u32 *status,
970-
u32 portsc, unsigned long flags)
970+
u32 portsc, unsigned long *flags)
971971
{
972972
struct xhci_bus_state *bus_state;
973973
u32 link_state;
@@ -1017,7 +1017,7 @@ static void xhci_get_usb2_port_status(struct xhci_port *port, u32 *status,
10171017
static u32 xhci_get_port_status(struct usb_hcd *hcd,
10181018
struct xhci_bus_state *bus_state,
10191019
u16 wIndex, u32 raw_port_status,
1020-
unsigned long flags)
1020+
unsigned long *flags)
10211021
__releases(&xhci->lock)
10221022
__acquires(&xhci->lock)
10231023
{
@@ -1140,7 +1140,7 @@ int xhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
11401140
}
11411141
trace_xhci_get_port_status(wIndex, temp);
11421142
status = xhci_get_port_status(hcd, bus_state, wIndex, temp,
1143-
flags);
1143+
&flags);
11441144
if (status == 0xffffffff)
11451145
goto error;
11461146

0 commit comments

Comments
 (0)