Linux USB
 help / color / mirror / Atom feed
* [PATCH] usb: renesas_usbhs: Stop an active host on removal
@ 2026-11-29 16:31 Guangshuo Li
  2026-11-29 16:48 ` sashiko-bot
  0 siblings, 1 reply; 2+ messages in thread
From: Guangshuo Li @ 2026-11-29 16:31 UTC (permalink / raw)
  To: gregkh, kuninori.morimoto.gx, balbi; +Cc: linux-usb

The platform remove path drops the host controller reference without
deregistering an active root hub. Disable hotplug work before teardown
and stop the current host while its registers and power are still
available.

A failed usb_add_hcd() leaves no root hub. Skip host teardown in that
case, as on a host that was never started.

This issue was found by our static analysis tool under development.

Fixes: 034d7c13a79c ("usb: gadget: renesas_usbhs: add mod_host support")
Signed-off-by: Guangshuo Li <liguangshuo@mail.sdu.edu.cn>
---
 drivers/usb/renesas_usbhs/common.c   | 9 ++++++++-
 drivers/usb/renesas_usbhs/mod_host.c | 3 +++
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/renesas_usbhs/common.c b/drivers/usb/renesas_usbhs/common.c
index 22a5175dcceb..6e3c6891b6b4 100644
--- a/drivers/usb/renesas_usbhs/common.c
+++ b/drivers/usb/renesas_usbhs/common.c
@@ -811,7 +811,7 @@ static void usbhs_remove(struct platform_device *pdev)
 
 	dev_dbg(&pdev->dev, "usb remove\n");
 
-	flush_delayed_work(&priv->notify_hotplug_work);
+	disable_delayed_work_sync(&priv->notify_hotplug_work);
 
 	/*
 	 * Explicitly free the IRQ to ensure the interrupt handler is
@@ -821,6 +821,13 @@ static void usbhs_remove(struct platform_device *pdev)
 	 */
 	devm_free_irq(&pdev->dev, priv->irq, priv);
 
+	if (usbhs_mod_is_host(priv) > 0) {
+		usbhs_mod_call(priv, stop, priv);
+		usbhs_mod_change(priv, -1);
+		if (usbhs_get_dparam(priv, runtime_pwctrl))
+			usbhsc_power_ctrl(priv, 0);
+	}
+
 	usbhs_mod_remove(priv);
 	usbhs_fifo_remove(priv);
 	usbhs_pipe_remove(priv);
diff --git a/drivers/usb/renesas_usbhs/mod_host.c b/drivers/usb/renesas_usbhs/mod_host.c
index f7ef3a9f82a4..8caa17282061 100644
--- a/drivers/usb/renesas_usbhs/mod_host.c
+++ b/drivers/usb/renesas_usbhs/mod_host.c
@@ -1496,6 +1496,9 @@ static int usbhsh_stop(struct usbhs_priv *priv)
 	struct usbhs_mod *mod = usbhs_mod_get_current(priv);
 	struct device *dev = usbhs_priv_to_dev(priv);
 
+	if (!hcd->self.root_hub)
+		return 0;
+
 	/*
 	 * disable irq callback
 	 */

base-commit: 90d6263e867be7089b3d3323bef8d2accd327c77
-- 
2.43.0


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

end of thread, other threads:[~2026-11-29 16:48 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-29 16:31 [PATCH] usb: renesas_usbhs: Stop an active host on removal Guangshuo Li
2026-11-29 16:48 ` sashiko-bot

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