summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNiklas Neronin <niklas.neronin@linux.intel.com>2026-11-05 19:51:06 +0200
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2026-11-05 16:01:00 -0500
commit3149e8b3237f58d4dd440fc64c45c93404c4b064 (patch)
tree57e128f978c08cda709cb0333a2e83f35987d1c5
parentd1ec1859f3b8641e3e5c5953cc7dd8e63b54339f (diff)
usb: xhci: fix 'num_active_eps' accounting on allocation failure
For controllers affected by XHCI_EP_LIMIT_QUIRK, endpoint resources for the default control endpoint are accounted before the virtual device is allocated. If xhci_alloc_virt_device() fails, the slot is disabled and cleanup is handled through the Disable Slot completion path. However, because no virtual device is installed in 'xhci->devs', the endpoint accounting is never released and 'num_active_eps' remains incremented. As a result, each allocation failure leaks one endpoint from the driver's accounting. Fix this by undoing the endpoint reservation when virtual device allocation fails. Signed-off-by: Niklas Neronin <niklas.neronin@linux.intel.com> Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com> Link: https://patch.msgid.link/20261105175106.241182-6-mathias.nyman@linux.intel.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/usb/host/xhci.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
index a762dd010e8d..fc1b0a6b0429 100644
--- a/drivers/usb/host/xhci.c
+++ b/drivers/usb/host/xhci.c
@@ -4280,6 +4280,11 @@ int xhci_alloc_dev(struct usb_hcd *hcd, struct usb_device *udev)
*/
if (!xhci_alloc_virt_device(xhci, slot_id, udev, GFP_NOIO)) {
xhci_warn(xhci, "Could not allocate xHCI USB device data structures\n");
+ if (xhci->quirks & XHCI_EP_LIMIT_QUIRK) {
+ spin_lock_irqsave(&xhci->lock, flags);
+ xhci->num_active_eps -= 1;
+ spin_unlock_irqrestore(&xhci->lock, flags);
+ }
goto disable_slot;
}
vdev = xhci->devs[slot_id];