watchdog: sprd_wdt: Fix error handling in sprd_wdt_enable()

If clk_prepare_enable(wdt->rtc_enable) fails,
wdt->enable clock is left enabled.

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

Signed-off-by: Alexey Khoroshilov <khoroshilov@ispras.ru>
Reviewed-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Wim Van Sebroeck <wim@iguana.be>
This commit is contained in:
Alexey Khoroshilov 2018-03-09 00:21:48 +03:00 committed by Wim Van Sebroeck
parent d2fc8db691
commit 3c578cd4bc
1 changed files with 3 additions and 1 deletions

View File

@ -154,8 +154,10 @@ static int sprd_wdt_enable(struct sprd_wdt *wdt)
if (ret)
return ret;
ret = clk_prepare_enable(wdt->rtc_enable);
if (ret)
if (ret) {
clk_disable_unprepare(wdt->enable);
return ret;
}
sprd_wdt_unlock(wdt->base);
val = readl_relaxed(wdt->base + SPRD_WDT_CTRL);