mirror of
https://github.com/brain-hackers/u-boot-brain
synced 2024-06-09 23:36:03 +09:00
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>
This commit is contained in:
parent
1884512b77
commit
8dfb5e6e21
|
@ -1364,28 +1364,28 @@ static efi_status_t efi_locate_handle(
|
||||||
return EFI_INVALID_PARAMETER;
|
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 */
|
/* Count how much space we need */
|
||||||
list_for_each_entry(efiobj, &efi_obj_list, link) {
|
list_for_each_entry(efiobj, &efi_obj_list, link) {
|
||||||
if (!efi_search(search_type, protocol, search_key, efiobj))
|
if (!efi_search(search_type, protocol, search_key, efiobj))
|
||||||
size += sizeof(void *);
|
size += sizeof(void *);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (size == 0)
|
||||||
|
return EFI_NOT_FOUND;
|
||||||
|
|
||||||
|
if (!buffer_size)
|
||||||
|
return EFI_INVALID_PARAMETER;
|
||||||
|
|
||||||
if (*buffer_size < size) {
|
if (*buffer_size < size) {
|
||||||
*buffer_size = size;
|
*buffer_size = size;
|
||||||
return EFI_BUFFER_TOO_SMALL;
|
return EFI_BUFFER_TOO_SMALL;
|
||||||
}
|
}
|
||||||
|
|
||||||
*buffer_size = size;
|
*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 */
|
/* Then fill the array */
|
||||||
list_for_each_entry(efiobj, &efi_obj_list, link) {
|
list_for_each_entry(efiobj, &efi_obj_list, link) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user