From: Wentao Liang <vulab@iscas.ac.cn>
To: gregkh@linuxfoundation.org
Cc: linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org,
mathias.nyman@intel.com, sarah.a.sharp@linux.intel.com,
Wentao Liang <vulab@iscas.ac.cn>,
stable@vger.kernel.org
Subject: [PATCH] usb: host: Fix companion leak in usb_enable_intel_xhci_ports()
Date: Wed, 16 Sep 2026 16:48:40 +0000 [thread overview]
Message-ID: <20260916164840.2085101-1-vulab@iscas.ac.cn> (raw)
usb_enable_intel_xhci_ports() iterates over the PCI devices with
for_each_pci_dev() to check whether an Intel EHCI companion exists and
breaks out of the loop as soon as one is found. for_each_pci_dev()
takes a reference on the device returned by pci_get_device(), and
breaking out of the loop leaves that reference held. The companion
pointer is only used to set the ehci_found flag and the reference is
never dropped, leaking a reference to the EHCI companion device on
every port switch operation.
Drop the reference with pci_dev_put() once the lookup is done. When no
companion is found the loop leaves companion set to NULL, for which
pci_dev_put() is a no-op.
Fixes: 26b76798e050 ("Intel xhci: refactor EHCI/xHCI port switching")
Cc: stable@vger.kernel.org
Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
---
drivers/usb/host/pci-quirks.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/usb/host/pci-quirks.c b/drivers/usb/host/pci-quirks.c
index 0404489c2f6a..bde5bc248d45 100644
--- a/drivers/usb/host/pci-quirks.c
+++ b/drivers/usb/host/pci-quirks.c
@@ -1076,6 +1076,8 @@ void usb_enable_intel_xhci_ports(struct pci_dev *xhci_pdev)
break;
}
}
+ /* for_each_pci_dev() takes a reference on the found companion */
+ pci_dev_put(companion);
if (!ehci_found)
return;
--
2.34.1
next reply other threads:[~2026-09-16 16:49 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-16 16:48 Wentao Liang [this message]
2026-09-30 13:27 ` [PATCH] usb: host: Fix companion leak in usb_enable_intel_xhci_ports() Mathias Nyman
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=20260916164840.2085101-1-vulab@iscas.ac.cn \
--to=vulab@iscas.ac.cn \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=mathias.nyman@intel.com \
--cc=sarah.a.sharp@linux.intel.com \
--cc=stable@vger.kernel.org \
/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