Skip to content

Commit 97264ea

Browse files
vmordangregkh
authored andcommitted
usb: ehci-hcd: fix call balance of clocks handling routines
If the clocks priv->iclk and priv->fclk were not enabled in ehci_hcd_sh_probe, they should not be disabled in any path. Conversely, if they was enabled in ehci_hcd_sh_probe, they must be disabled in all error paths to ensure proper cleanup. Found by Linux Verification Center (linuxtesting.org) with Klever. Fixes: 63c8455 ("usb: ehci-hcd: Add support for SuperH EHCI.") Cc: [email protected] # ff30bd6: sh: clk: Fix clk_enable() to return 0 on NULL clk Signed-off-by: Vitalii Mordan <[email protected]> Reviewed-by: Alan Stern <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent cdd30eb commit 97264ea

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

drivers/usb/host/ehci-sh.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,12 @@ static int ehci_hcd_sh_probe(struct platform_device *pdev)
119119
if (IS_ERR(priv->iclk))
120120
priv->iclk = NULL;
121121

122-
clk_enable(priv->fclk);
123-
clk_enable(priv->iclk);
122+
ret = clk_enable(priv->fclk);
123+
if (ret)
124+
goto fail_request_resource;
125+
ret = clk_enable(priv->iclk);
126+
if (ret)
127+
goto fail_iclk;
124128

125129
ret = usb_add_hcd(hcd, irq, IRQF_SHARED);
126130
if (ret != 0) {
@@ -136,6 +140,7 @@ static int ehci_hcd_sh_probe(struct platform_device *pdev)
136140

137141
fail_add_hcd:
138142
clk_disable(priv->iclk);
143+
fail_iclk:
139144
clk_disable(priv->fclk);
140145

141146
fail_request_resource:

0 commit comments

Comments
 (0)