diff options
author | Sean Anderson <seanga2@gmail.com> | 2021-03-10 21:02:20 -0500 |
---|---|---|
committer | Leo Yu-Chi Liang <ycliang@andestech.com> | 2021-04-08 15:37:27 +0800 |
commit | 97bcdd28addde4233b6c53c03712eed5a807854c (patch) | |
tree | 91e743c19f7cc8e9417447e7b9817503a02e022d /drivers/watchdog | |
parent | 4cb0ab4ebcffbeee93d9bdb4e8ee831e16bc8d2c (diff) | |
download | u-boot-97bcdd28addde4233b6c53c03712eed5a807854c.zip u-boot-97bcdd28addde4233b6c53c03712eed5a807854c.tar.gz u-boot-97bcdd28addde4233b6c53c03712eed5a807854c.tar.bz2 |
wdt: dw: Free the clock on error
The clock subsystem requires that clk_free be called on clocks obtained via
clk_get_*.
Signed-off-by: Sean Anderson <seanga2@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'drivers/watchdog')
-rw-r--r-- | drivers/watchdog/designware_wdt.c | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/drivers/watchdog/designware_wdt.c b/drivers/watchdog/designware_wdt.c index 709a67f..9e54871 100644 --- a/drivers/watchdog/designware_wdt.c +++ b/drivers/watchdog/designware_wdt.c @@ -131,11 +131,13 @@ static int designware_wdt_probe(struct udevice *dev) ret = clk_enable(&clk); if (ret) - return ret; + goto err; priv->clk_khz = clk_get_rate(&clk) / 1000; - if (!priv->clk_khz) - return -EINVAL; + if (!priv->clk_khz) { + ret = -EINVAL; + goto err; + } #else priv->clk_khz = CONFIG_DW_WDT_CLOCK_KHZ; #endif @@ -145,15 +147,21 @@ static int designware_wdt_probe(struct udevice *dev) ret = reset_get_bulk(dev, &resets); if (ret) - return ret; + goto err; ret = reset_deassert_bulk(&resets); if (ret) - return ret; + goto err; } /* reset to disable the watchdog */ return designware_wdt_stop(dev); + +err: +#if CONFIG_IS_ENABLED(CLK) + clk_free(&clk); +#endif + return ret; } static const struct wdt_ops designware_wdt_ops = { |