boot: fix vbe_find_first_device()

uclass_find_first_device() may return NULL if no device for the uclass
exists. Handle this case gracefully.

Addresses-Coverity: CID 356244 ("Null pointer dereferences (FORWARD_NULL)")
Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
Heinrich Schuchardt 2022-08-23 10:25:25 +02:00 committed by Simon Glass
parent a7091f3f8c
commit d81eeacd48

View File

@ -40,7 +40,7 @@ int vbe_find_next_device(struct udevice **devp)
int vbe_find_first_device(struct udevice **devp)
{
uclass_find_first_device(UCLASS_BOOTMETH, devp);
if (*devp && is_vbe(*devp))
if (!*devp || is_vbe(*devp))
return 0;
return vbe_find_next_device(devp);