mirror of
https://source.denx.de/u-boot/u-boot.git
synced 2026-05-04 20:26:13 +02:00
efi_loader: efi_realloc() must check efi_alloc() return value
Avoid copying to NULL if out of memory.
Fixes: 3c08df58cc43 ("lib: efi_loader: efi_memory.c: add efi_realloc() for realloc memory")
Addresses-Coverity-ID: 569499: Null pointer dereferences (NULL_RETURNS)
Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
This commit is contained in:
parent
b9bb2627bb
commit
aa703a816a
@ -714,6 +714,8 @@ efi_status_t efi_realloc(void **ptr, size_t size)
|
||||
sizeof(struct efi_pool_allocation);
|
||||
|
||||
new_ptr = efi_alloc(size);
|
||||
if (!new_ptr)
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
|
||||
/* copy old data to new alloced buffer */
|
||||
memcpy(new_ptr, *ptr, min(size, old_size));
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user