[PATCH 1/6] clk: Handle error pointers in clk_valid()

Michal Suchánek msuchanek at suse.de
Mon Feb 20 11:46:18 CET 2023


On Sun, Feb 19, 2023 at 11:59:34PM -0600, Samuel Holland wrote:
> Some clk uclass functions, such as devm_clk_get() and clk_get_parent(),
> return error pointers. clk_valid() should not consider these pointers
> to be valid.
> 
> Fixes: 8a1661f20e6c ("drivers: clk: Handle gracefully NULL pointers")
> Signed-off-by: Samuel Holland <samuel at sholland.org>
> ---
> 
>  include/clk.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/include/clk.h b/include/clk.h
> index d91285235f7..4acb878ec6d 100644
> --- a/include/clk.h
> +++ b/include/clk.h
> @@ -671,7 +671,7 @@ static inline bool clk_dev_binded(struct clk *clk)
>   */
>  static inline bool clk_valid(struct clk *clk)
>  {
> -	return clk && !!clk->dev;
> +	return clk && !IS_ERR(clk) && !!clk->dev;
>  }
>  
>  int soc_clk_dump(void);

Maybe it would be better to avoid the error pointers instead, there
should not be that many places where they are returned.

Thanks

Michal


More information about the U-Boot mailing list