summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorHeinrich Schuchardt <xypron.glpk@gmx.de>2019-05-04 17:37:32 +0200
committerHeinrich Schuchardt <xypron.glpk@gmx.de>2019-05-07 21:10:03 +0200
commit8dfb5e6e211fb9d6e1c6650617377a99342224ae (patch)
tree7aeac221c96644aa97ac12518a1b3c1ca35701ef /lib
parent1884512b77ce54fffa50bb07cf065d4831171a6d (diff)
efi_loader: correct parameter check in LocateHandle()
If LocateHandle() does not find an entry EFI_NOT_FOUND has to be returned even if BufferSize is NULL. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Diffstat (limited to 'lib')
-rw-r--r--lib/efi_loader/efi_boottime.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c
index 3ed08e7c377..0c92cc1807c 100644
--- a/lib/efi_loader/efi_boottime.c
+++ b/lib/efi_loader/efi_boottime.c
@@ -1364,28 +1364,28 @@ static efi_status_t efi_locate_handle(
return EFI_INVALID_PARAMETER;
}
- /*
- * efi_locate_handle_buffer uses this function for
- * the calculation of the necessary buffer size.
- * So do not require a buffer for buffersize == 0.
- */
- if (!buffer_size || (*buffer_size && !buffer))
- return EFI_INVALID_PARAMETER;
-
/* Count how much space we need */
list_for_each_entry(efiobj, &efi_obj_list, link) {
if (!efi_search(search_type, protocol, search_key, efiobj))
size += sizeof(void *);
}
+ if (size == 0)
+ return EFI_NOT_FOUND;
+
+ if (!buffer_size)
+ return EFI_INVALID_PARAMETER;
+
if (*buffer_size < size) {
*buffer_size = size;
return EFI_BUFFER_TOO_SMALL;
}
*buffer_size = size;
- if (size == 0)
- return EFI_NOT_FOUND;
+
+ /* The buffer size is sufficient but there is not buffer */
+ if (!buffer)
+ return EFI_INVALID_PARAMETER;
/* Then fill the array */
list_for_each_entry(efiobj, &efi_obj_list, link) {