Skip to content

Commit 0b1d9de

Browse files
committed
efi/libstub: randomalloc: Return EFI_OUT_OF_RESOURCES on failure
The logic in efi_random_alloc() will iterate over the memory map twice, once to count the number of candidate slots, and another time to locate the chosen slot after randomization. If there is insufficient memory to do the allocation, the second loop will run to completion without actually having located a slot, but we currently return EFI_SUCCESS in this case, as we fail to initialize status to the appropriate error value of EFI_OUT_OF_RESOURCES. Signed-off-by: Ard Biesheuvel <[email protected]>
1 parent fc3608a commit 0b1d9de

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

drivers/firmware/efi/libstub/randomalloc.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ efi_status_t efi_random_alloc(unsigned long size,
101101
* to calculate the randomly chosen address, and allocate it directly
102102
* using EFI_ALLOCATE_ADDRESS.
103103
*/
104+
status = EFI_OUT_OF_RESOURCES;
104105
for (map_offset = 0; map_offset < map->map_size; map_offset += map->desc_size) {
105106
efi_memory_desc_t *md = (void *)map->map + map_offset;
106107
efi_physical_addr_t target;

0 commit comments

Comments
 (0)