Skip to content

Commit 5b586a7

Browse files
author
Desnes Nunes
committed
usb: ehci-hcd: fix call balance of clocks handling routines
JIRA: https://issues.redhat.com/browse/RHEL-78828 commit 97264ea Author: Vitalii Mordan <mordan@ispras.ru> Date: Thu, 21 Nov 2024 14:47:00 +0300 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: stable@vger.kernel.org # ff30bd6: sh: clk: Fix clk_enable() to return 0 on NULL clk Signed-off-by: Vitalii Mordan <mordan@ispras.ru> Reviewed-by: Alan Stern <stern@rowland.harvard.edu> Link: https://lore.kernel.org/r/20241121114700.2100520-1-mordan@ispras.ru Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Desnes Nunes <desnesn@redhat.com>
1 parent 6639b1e commit 5b586a7

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)