summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGriffin Kroah-Hartman <griffin@kroah.com>2026-07-13 18:43:53 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2026-09-02 15:28:36 +0300
commit71cfda2fdf78041a01e9d94143baa79feabbdbf6 (patch)
treeeb90fc89d2482d347fd551438693c934d995e3ad
parentebf6edaf487143e9793b5370f6c3c7e1741f7046 (diff)
downloadlinux-71cfda2fdf78041a01e9d94143baa79feabbdbf6.tar.xz
usb: core: Add lock to usb_wakeup_notification()
commit e263e18a9e7b1ff3e7301f0801c6ff87c31adfb6 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>
-rw-r--r--drivers/usb/core/hub.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index 5c8400dc7923..3c5e212295fa 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -727,10 +727,12 @@ void usb_wakeup_notification(struct usb_device *hdev,
{
struct usb_hub *hub;
struct usb_port *port_dev;
+ unsigned long flags;
if (!hdev)
return;
+ spin_lock_irqsave(&device_state_lock, flags);
hub = usb_hub_to_struct_hub(hdev);
if (hub) {
port_dev = hub->ports[portnum - 1];
@@ -740,6 +742,7 @@ void usb_wakeup_notification(struct usb_device *hdev,
set_bit(portnum, hub->wakeup_bits);
kick_hub_wq(hub);
}
+ spin_unlock_irqrestore(&device_state_lock, flags);
}
EXPORT_SYMBOL_GPL(usb_wakeup_notification);