Linux USB
 help / color / mirror / Atom feed
* [PATCH] usb: core: hcd: drop the root hub reference if it was not registered
@ 2026-11-04  2:15 Wentao Liang
  2026-11-04  2:28 ` sashiko-bot
  0 siblings, 1 reply; 2+ messages in thread
From: Wentao Liang @ 2026-11-04  2:15 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: linux-usb

usb_remove_hcd() takes an extra reference to the root hub and relies on
usb_disconnect() to drop the reference held by hcd->self.root_hub before
usb_put_invalidate_rhdev() drops the extra one. If the root hub was
never registered - for example when xHCI defers registration and adding
the shared HCD fails - usb_disconnect() is skipped, so the reference
held by hcd->self.root_hub is leaked and the root hub device and its
HCD reference are never released.

Drop the extra reference in that case.

Fixes: a44623d92790 ("usb: core: hcd: Add support for deferring roothub registration")
Cc: stable@vger.kernel.org
Assisted-by: DeepSeek-V4.1-Flash and OpenAI Codex
Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
---
 drivers/usb/core/hcd.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
index 8e8a5f59b319..1d4a303307ec 100644
--- a/drivers/usb/core/hcd.c
+++ b/drivers/usb/core/hcd.c
@@ -3057,6 +3057,8 @@ void usb_remove_hcd(struct usb_hcd *hcd)
 	mutex_lock(&usb_bus_idr_lock);
 	if (rh_registered)
 		usb_disconnect(&rhdev);		/* Sets rhdev to NULL */
+	else
+		usb_put_dev(rhdev);
 	mutex_unlock(&usb_bus_idr_lock);
 
 	/*
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] usb: core: hcd: drop the root hub reference if it was not registered
  2026-11-04  2:15 [PATCH] usb: core: hcd: drop the root hub reference if it was not registered Wentao Liang
@ 2026-11-04  2:28 ` sashiko-bot
  0 siblings, 0 replies; 2+ messages in thread
From: sashiko-bot @ 2026-11-04  2:28 UTC (permalink / raw)
  To: Wentao Liang; +Cc: linux-usb

> usb_remove_hcd() takes an extra reference to the root hub and relies on
> usb_disconnect() to drop the reference held by hcd->self.root_hub before
> usb_put_invalidate_rhdev() drops the extra one. If the root hub was
> never registered - for example when xHCI defers registration and adding
> the shared HCD fails - usb_disconnect() is skipped, so the reference
> held by hcd->self.root_hub is leaked and the root hub device and its
> HCD reference are never released.
> 
> Drop the extra reference in that case.
> 
> Fixes: a44623d92790 ("usb: core: hcd: Add support for deferring roothub registration")
> Cc: stable@vger.kernel.org
> Assisted-by: DeepSeek-V4.1-Flash and OpenAI Codex
> Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>

Sashiko has reviewed this patch and found no issues.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261104021511.1468577-1-vulab@iscas.ac.cn?part=1


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-11-04  2:28 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-04  2:15 [PATCH] usb: core: hcd: drop the root hub reference if it was not registered Wentao Liang
2026-11-04  2:28 ` sashiko-bot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox