[PATCH v2] usb: xhci: fix runtime PM usage count leak in xhci_port_bw_show()

From: Wentao Liang

Date: Mon Jun 22 2026 - 07:02:13 EST


When xhci_port_bw_show() calls pm_runtime_get_sync() and it fails with
a negative return value, the function returns the error directly without
calling pm_runtime_put_noidle(). This leaks the runtime PM usage count,
preventing the device from ever suspending again.

pm_runtime_get_sync() unconditionally increments dev->power.usage_count
before calling rpm_resume(). If rpm_resume() fails, the usage count is
not decremented — a well-known API pitfall. Add a pm_runtime_put_noidle()
call on the error path to balance the reference.

Cc: stable@xxxxxxxxxxxxxxx
Fixes: 59d50e53e070 ("usb: xhci: Add debugfs support for xHCI port bandwidth")
Signed-off-by: Wentao Liang <vulab@xxxxxxxxxxx>
---
drivers/usb/host/xhci-debugfs.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/host/xhci-debugfs.c b/drivers/usb/host/xhci-debugfs.c
index d07276192256..2974411f775d 100644
--- a/drivers/usb/host/xhci-debugfs.c
+++ b/drivers/usb/host/xhci-debugfs.c
@@ -679,8 +679,10 @@ static int xhci_port_bw_show(struct xhci_hcd *xhci, u8 dev_speed,
struct device *dev = hcd->self.controller;

ret = pm_runtime_get_sync(dev);
- if (ret < 0)
+ if (ret < 0) {
+ pm_runtime_put_noidle(dev);
return ret;
+ }

ctx = xhci_alloc_port_bw_ctx(xhci, 0);
if (!ctx) {
--
2.39.5 (Apple Git-154)