efi/libstub: randomalloc: Return EFI_OUT_OF_RESOURCES on failure
authorArd Biesheuvel <ardb@kernel.org>
Tue, 7 Mar 2023 23:21:34 +0000 (00:21 +0100)
committerArd Biesheuvel <ardb@kernel.org>
Thu, 23 Mar 2023 14:15:45 +0000 (15:15 +0100)
commit0b1d9debe30304f35c1211e6dcdca1935ce67240
treeabc1768b13ab8caf800a07bab2e89b6e66b873a3
parentfc3608aaa5751318837e4bbe0282b3836bca5080
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 <ardb@kernel.org>
drivers/firmware/efi/libstub/randomalloc.c