[PATCH v3 5/7] wdt: dw: Free the clock on error

Sean Anderson seanga2 at gmail.com
Wed Sep 9 22:57:22 CEST 2020


On 9/1/20 4:07 PM, Sean Anderson wrote:
> The clock subsystem requires that clk_free be called on clocks obtained via
> clk_get_*.
> 
> Signed-off-by: Sean Anderson <seanga2 at gmail.com>
> Reviewed-by: Simon Glass <sjg at chromium.org>
> ---
> 
> (no changes since v1)
> 
>  drivers/watchdog/designware_wdt.c | 17 ++++++++++++-----
>  1 file changed, 12 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/watchdog/designware_wdt.c b/drivers/watchdog/designware_wdt.c
> index e6f5437056..189d555f29 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,20 @@ 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))

This should be an #if. Found by running CI at

https://dev.azure.com/seanga2/u-boot/_build/results?buildId=26&view=logs&jobId=673723c4-497f-506b-4750-995fcb7877b8&j=673723c4-497f-506b-4750-995fcb7877b8&t=b5278753-2bf3-55ba-a142-eaf3481f5b3e

Will be fixed in v4.

--Sean

> +		clk_free(&clk);
> +	return ret;
>  }
>  
>  static const struct wdt_ops designware_wdt_ops = {
> 



More information about the U-Boot mailing list