efi_loader: LocateHandle should return EFI_NOT_FOUND if none found
authorRob Clark <robdclark@gmail.com>
Sun, 6 Aug 2017 18:10:07 +0000 (14:10 -0400)
committerAlexander Graf <agraf@suse.de>
Fri, 11 Aug 2017 09:08:33 +0000 (11:08 +0200)
Spotted this debugging OpenBSD's bootloader in qemu.  (Wouldn't really
fix anything, the problem was not having any disks, but we should
probably return the correct error code.)

Signed-off-by: Rob Clark <robdclark@gmail.com>
Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Signed-off-by: Alexander Graf <agraf@suse.de>
lib/efi_loader/efi_boottime.c

index 58cd6d0e894f4f1f359acac95f76b53f383c8116..43f32385fae01fbdbbcfdbae2e9c4d78e7918477 100644 (file)
@@ -633,6 +633,10 @@ static efi_status_t efi_locate_handle(
                return EFI_BUFFER_TOO_SMALL;
        }
 
+       *buffer_size = size;
+       if (size == 0)
+               return EFI_NOT_FOUND;
+
        /* Then fill the array */
        list_for_each(lhandle, &efi_obj_list) {
                struct efi_object *efiobj;
@@ -642,7 +646,6 @@ static efi_status_t efi_locate_handle(
                }
        }
 
-       *buffer_size = size;
        return EFI_SUCCESS;
 }