From: Mathias Nyman <mathias.nyman@linux.intel.com>
To: <gregkh@linuxfoundation.org>
Cc: <linux-usb@vger.kernel.org>,
Niklas Neronin <niklas.neronin@linux.intel.com>,
Mathias Nyman <mathias.nyman@linux.intel.com>
Subject: [PATCH 5/5] usb: xhci: fix 'num_active_eps' accounting on allocation failure
Date: Thu, 5 Nov 2026 19:51:06 +0200 [thread overview]
Message-ID: <20261105175106.241182-6-mathias.nyman@linux.intel.com> (raw)
In-Reply-To: <20261105175106.241182-1-mathias.nyman@linux.intel.com>
From: Niklas Neronin <niklas.neronin@linux.intel.com>
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>
---
drivers/usb/host/xhci.c | 5 +++++
1 file changed, 5 insertions(+)
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];
--
2.43.0
next prev parent reply other threads:[~2026-11-05 17:51 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-05 17:51 [PATCH 0/5] xhci fixes for usb-linus Mathias Nyman
2026-11-05 17:51 ` [PATCH 1/5] xhci: keep port link_inactive and connected flags in sync when polled Mathias Nyman
2026-11-05 17:56 ` sashiko-bot
2026-11-06 8:15 ` Xu Yang
2026-11-05 17:51 ` [PATCH 2/5] usb: xhci: disable the correct slot on alloc_dev failure Mathias Nyman
2026-11-05 18:06 ` sashiko-bot
2026-11-05 17:51 ` [PATCH 3/5] usb: pci-quirks: always assert xHCI OS ownership Mathias Nyman
2026-11-05 17:54 ` sashiko-bot
2026-11-05 17:51 ` [PATCH 4/5] usb: xhci: clear stale bandwidth data after hibernation Mathias Nyman
2026-11-05 17:56 ` sashiko-bot
2026-11-05 17:51 ` Mathias Nyman [this message]
2026-11-05 17:55 ` [PATCH 5/5] usb: xhci: fix 'num_active_eps' accounting on allocation failure sashiko-bot
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261105175106.241182-6-mathias.nyman@linux.intel.com \
--to=mathias.nyman@linux.intel.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-usb@vger.kernel.org \
--cc=niklas.neronin@linux.intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox