Skip to content

Commit 40c9748

Browse files
vmordangregkh
authored andcommitted
usb: ehci-spear: fix call balance of sehci clk handling routines
If the clock sehci->clk was not enabled in spear_ehci_hcd_drv_probe, it should not be disabled in any path. Conversely, if it was enabled in spear_ehci_hcd_drv_probe, it must be disabled in all error paths to ensure proper cleanup. Found by Linux Verification Center (linuxtesting.org) with Klever. Fixes: 7675d6b ("USB: EHCI: make ehci-spear a separate driver") Cc: [email protected] Signed-off-by: Vitalii Mordan <[email protected]> Acked-by: Alan Stern <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent aa03bda commit 40c9748

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

drivers/usb/host/ehci-spear.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,9 @@ static int spear_ehci_hcd_drv_probe(struct platform_device *pdev)
105105
/* registers start at offset 0x0 */
106106
hcd_to_ehci(hcd)->caps = hcd->regs;
107107

108-
clk_prepare_enable(sehci->clk);
108+
retval = clk_prepare_enable(sehci->clk);
109+
if (retval)
110+
goto err_put_hcd;
109111
retval = usb_add_hcd(hcd, irq, IRQF_SHARED);
110112
if (retval)
111113
goto err_stop_ehci;
@@ -130,8 +132,7 @@ static void spear_ehci_hcd_drv_remove(struct platform_device *pdev)
130132

131133
usb_remove_hcd(hcd);
132134

133-
if (sehci->clk)
134-
clk_disable_unprepare(sehci->clk);
135+
clk_disable_unprepare(sehci->clk);
135136
usb_put_hcd(hcd);
136137
}
137138

0 commit comments

Comments
 (0)