Skip to content

Commit

Permalink
usb: dwc3: exynos: Fix error handling of clk_prepare_enable
Browse files Browse the repository at this point in the history
If clk_prepare_enable() fails in dwc3_exynos_probe() or in
dwc3_exynos_resume(), exynos->clks[0] is left undisabled
because of usage preincrement in while condition.

Found by Linux Driver Verification project (linuxtesting.org).

Fixes: 9f21683 ("usb: dwc3: exynos: Rework clock handling and prepare for new variants")
Acked-by: Marek Szyprowski <[email protected]>
Signed-off-by: Alexey Khoroshilov <[email protected]>
Signed-off-by: Felipe Balbi <[email protected]>
  • Loading branch information
khoroshilov authored and Felipe Balbi committed Jan 28, 2019
1 parent f2105d4 commit 512e6fb
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions drivers/usb/dwc3/dwc3-exynos.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ static int dwc3_exynos_probe(struct platform_device *pdev)
for (i = 0; i < exynos->num_clks; i++) {
ret = clk_prepare_enable(exynos->clks[i]);
if (ret) {
while (--i > 0)
while (i-- > 0)
clk_disable_unprepare(exynos->clks[i]);
return ret;
}
Expand Down Expand Up @@ -223,7 +223,7 @@ static int dwc3_exynos_resume(struct device *dev)
for (i = 0; i < exynos->num_clks; i++) {
ret = clk_prepare_enable(exynos->clks[i]);
if (ret) {
while (--i > 0)
while (i-- > 0)
clk_disable_unprepare(exynos->clks[i]);
return ret;
}
Expand Down

0 comments on commit 512e6fb

Please sign in to comment.