Commit 512e6fb5 authored by Alexey Khoroshilov's avatar Alexey Khoroshilov Committed by Felipe Balbi

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: 9f216836 ("usb: dwc3: exynos: Rework clock handling and prepare for new variants")
Acked-by: default avatarMarek Szyprowski <m.szyprowski@samsung.com>
Signed-off-by: default avatarAlexey Khoroshilov <khoroshilov@ispras.ru>
Signed-off-by: default avatarFelipe Balbi <felipe.balbi@linux.intel.com>
parent f2105d42
......@@ -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;
}
......@@ -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;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment