[PATCH v2] usb: host: ehci-atmel: stop clocks before releasing HCD
From: Hongyan Xu
Date: Sun Nov 15 2026 - 06:49:19 EST
usb_put_hcd() can release the HCD and its private data. Calling
atmel_stop_ehci() afterwards retrieves that HCD from platform data
and accesses its private clock state.
Stop the controller clocks after usb_remove_hcd() has quiesced the
host, but before dropping the driver's HCD reference. This matches
the probe error unwind, which already stops the clocks before
usb_put_hcd().
Found by the author's in-house static analysis tool.
Fixes: 501c9c0802d9 ("USB: at91: Add USB EHCI driver for at91sam9g45 series")
Cc: stable@xxxxxxxxxxxxxxx
Link: https://lore.kernel.org/all/20260806060557.1747-1-getshell@xxxxxxxxxx/
Acked-by: Alan Stern <stern@xxxxxxxxxxxxxxxxxxx>
Signed-off-by: Hongyan Xu <getshell@xxxxxxxxxx>
Signed-off-by: Zehao Gao <gaozehao@xxxxxxxxx>
---
Discovery: found by the author's in-house static analysis tool.
drivers/usb/host/ehci-atmel.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/drivers/usb/host/ehci-atmel.c b/drivers/usb/host/ehci-atmel.c
index 6574727..bcd56f8 100644
--- a/drivers/usb/host/ehci-atmel.c
+++ b/drivers/usb/host/ehci-atmel.c
@@ -177,9 +177,8 @@ static void ehci_atmel_drv_remove(struct platform_device *pdev)
struct usb_hcd *hcd = platform_get_drvdata(pdev);
usb_remove_hcd(hcd);
- usb_put_hcd(hcd);
-
atmel_stop_ehci(pdev);
+ usb_put_hcd(hcd);
}
static int __maybe_unused ehci_atmel_drv_suspend(struct device *dev)
--
2.50.1.windows.1