[PATCH v2] USB: ohci-spear: check clk_prepare_enable in probe

From: Tang Bin

Date: Tue Oct 27 2026 - 05:29:05 EST


spear_ohci_hcd_drv_probe() ignored the return of
clk_prepare_enable(sohci_p->clk). On failure usb_add_hcd() runs unclocked
and the error path clk_disable_unprepare() would unbalance the count. Check
the return and bail to err_put_hcd on failure.

Fixes: 1cc6ac59ffaa ("USB: OHCI: make ohci-spear a separate driver")
Cc: stable@xxxxxxxxxxxxxxx
Signed-off-by: Tang Bin <tangbin@xxxxxxxxxxxxxxxxxxxx>
---
Changes in v2:
- Added Cc: stable@xxxxxxxxxxxxxxx as suggested by Greg KH.
- Found by code inspection comparing with ehci-spear.c (which already has this fix).
- Compile-tested only, no physical hardware available.

drivers/usb/host/ohci-spear.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/host/ohci-spear.c b/drivers/usb/host/ohci-spear.c
index 5aeabb051..9d93b3f86 100644
--- a/drivers/usb/host/ohci-spear.c
+++ b/drivers/usb/host/ohci-spear.c
@@ -80,7 +80,9 @@ static int spear_ohci_hcd_drv_probe(struct platform_device *pdev)
sohci_p = to_spear_ohci(hcd);
sohci_p->clk = usbh_clk;

- clk_prepare_enable(sohci_p->clk);
+ retval = clk_prepare_enable(sohci_p->clk);
+ if (retval)
+ goto err_put_hcd;

retval = usb_add_hcd(hcd, irq, 0);
if (retval == 0) {
--
2.52.0.windows.1