]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
boot: fix vbe_find_first_device()
authorHeinrich Schuchardt <heinrich.schuchardt@canonical.com>
Tue, 23 Aug 2022 08:25:25 +0000 (10:25 +0200)
committerSimon Glass <sjg@chromium.org>
Fri, 26 Aug 2022 22:32:59 +0000 (16:32 -0600)
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>
boot/vbe.c

index e6ee087dc24919526a521db94452328b543fd365..52b328300374fab943c584810f4bf13140edf1d8 100644 (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);