[U-Boot] [PATCH 02/48] dm: core: Check for empty list in uclass_find_device()

Bin Meng bmeng.cn at gmail.com
Thu Jul 23 04:14:44 CEST 2015


On Wed, Jul 22, 2015 at 11:48 PM, Simon Glass <sjg at chromium.org> wrote:
> This function needs to check the list has entries before traversing it.
> Fix this bug.
>
> Signed-off-by: Simon Glass <sjg at chromium.org>
> ---
>
>  drivers/core/uclass.c | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/drivers/core/uclass.c b/drivers/core/uclass.c
> index 7de8173..a930c30 100644
> --- a/drivers/core/uclass.c
> +++ b/drivers/core/uclass.c
> @@ -153,6 +153,8 @@ int uclass_find_device(enum uclass_id id, int index, struct udevice **devp)
>         ret = uclass_get(id, &uc);
>         if (ret)
>                 return ret;
> +       if (list_empty(&uc->dev_head))
> +               return 0;
>
>         list_for_each_entry(dev, &uc->dev_head, uclass_node) {
>                 if (!index--) {
> --

Reviewed-by: Bin Meng <bmeng.cn at gmail.com>


More information about the U-Boot mailing list