[PATCH 02/22] clk: check pointer returned by dev_get_parent()

Simon Glass sjg at chromium.org
Tue Aug 4 04:00:35 CEST 2020


Hi Claudiu,

On Wed, 29 Jul 2020 at 08:51, Claudiu Beznea
<claudiu.beznea at microchip.com> wrote:
>
> Check pointer returned by dev_get_parent().
>
> Signed-off-by: Claudiu Beznea <claudiu.beznea at microchip.com>
> ---
>  drivers/clk/clk-uclass.c | 3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/drivers/clk/clk-uclass.c b/drivers/clk/clk-uclass.c
> index 70df9d410f4c..aa1f11a27c41 100644
> --- a/drivers/clk/clk-uclass.c
> +++ b/drivers/clk/clk-uclass.c
> @@ -459,6 +459,9 @@ struct clk *clk_get_parent(struct clk *clk)
>                 return NULL;
>
>         pdev = dev_get_parent(clk->dev);
> +       if (!pdev)
> +               return ERR_PTR(-ENOMEM);

A clock device must always have a parent (e.g. the root device). So
this check is not useful and adds to code size.

> +
>         pclk = dev_get_clk_ptr(pdev);
>         if (!pclk)
>                 return ERR_PTR(-ENODEV);
> --
> 2.7.4
>

Regards,
Simon


More information about the U-Boot mailing list