Skip to content

Commit 512e6fb

Browse files
khoroshilovFelipe Balbi
authored andcommitted
usb: dwc3: exynos: Fix error handling of clk_prepare_enable
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 <m.szyprowski@samsung.com> Signed-off-by: Alexey Khoroshilov <khoroshilov@ispras.ru> Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
1 parent f2105d4 commit 512e6fb

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

drivers/usb/dwc3/dwc3-exynos.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ static int dwc3_exynos_probe(struct platform_device *pdev)
7878
for (i = 0; i < exynos->num_clks; i++) {
7979
ret = clk_prepare_enable(exynos->clks[i]);
8080
if (ret) {
81-
while (--i > 0)
81+
while (i-- > 0)
8282
clk_disable_unprepare(exynos->clks[i]);
8383
return ret;
8484
}
@@ -223,7 +223,7 @@ static int dwc3_exynos_resume(struct device *dev)
223223
for (i = 0; i < exynos->num_clks; i++) {
224224
ret = clk_prepare_enable(exynos->clks[i]);
225225
if (ret) {
226-
while (--i > 0)
226+
while (i-- > 0)
227227
clk_disable_unprepare(exynos->clks[i]);
228228
return ret;
229229
}

0 commit comments

Comments
 (0)