]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
efi_loader: out of memory in efi_add_memory_map_pg
authorHeinrich Schuchardt <heinrich.schuchardt@canonical.com>
Sun, 30 Jul 2023 10:36:17 +0000 (12:36 +0200)
committerHeinrich Schuchardt <heinrich.schuchardt@canonical.com>
Thu, 3 Aug 2023 07:21:02 +0000 (09:21 +0200)
Handle out of memory situation in efi_add_memory_map_pg().

Fixes: 5d00995c361c ("efi_loader: Implement memory allocation and map")
Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
lib/efi_loader/efi_memory.c

index e2ca78d935fae3e6a89a05f08a223f41918217d9..2c5d5221a75331d9b04c77c29d70ee90da096cc3 100644 (file)
@@ -282,6 +282,8 @@ static efi_status_t efi_add_memory_map_pg(u64 start, u64 pages,
 
        ++efi_memory_map_key;
        newlist = calloc(1, sizeof(*newlist));
+       if (!newlist)
+               return EFI_OUT_OF_RESOURCES;
        newlist->desc.type = memory_type;
        newlist->desc.physical_start = start;
        newlist->desc.virtual_start = start;