Skip to content

Commit 71cfda2

Browse files
griffinkhgregkh
authored andcommitted
usb: core: Add lock to usb_wakeup_notification()
commit e263e18 upstream. Add a spin lock to usb_wakeup notification to prevent a race condition with dereferencing freed memory. This could be hit by the xHCI driver as it calls this function from an IRQ and could race with the hub_disconnect() function, which properly grabs this lock to protect the state of the device. Assisted-by: gkh_clanker_t1000 Signed-off-by: Griffin Kroah-Hartman <griffin@kroah.com> Link: https://patch.msgid.link/20260713-usb_core_patches_1-v1-3-7721c2b33f53@kroah.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent ebf6eda commit 71cfda2

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

drivers/usb/core/hub.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -727,10 +727,12 @@ void usb_wakeup_notification(struct usb_device *hdev,
727727
{
728728
struct usb_hub *hub;
729729
struct usb_port *port_dev;
730+
unsigned long flags;
730731

731732
if (!hdev)
732733
return;
733734

735+
spin_lock_irqsave(&device_state_lock, flags);
734736
hub = usb_hub_to_struct_hub(hdev);
735737
if (hub) {
736738
port_dev = hub->ports[portnum - 1];
@@ -740,6 +742,7 @@ void usb_wakeup_notification(struct usb_device *hdev,
740742
set_bit(portnum, hub->wakeup_bits);
741743
kick_hub_wq(hub);
742744
}
745+
spin_unlock_irqrestore(&device_state_lock, flags);
743746
}
744747
EXPORT_SYMBOL_GPL(usb_wakeup_notification);
745748

0 commit comments

Comments
 (0)