[PATCH 1/1] efi_loader: out of memory in efi_add_memory_map_pg
    Heinrich Schuchardt 
    heinrich.schuchardt at canonical.com
       
    Sun Jul 30 12:37:46 CEST 2023
    
    
  
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 at canonical.com>
---
 lib/efi_loader/efi_memory.c | 2 ++
 1 file changed, 2 insertions(+)
diff --git a/lib/efi_loader/efi_memory.c b/lib/efi_loader/efi_memory.c
index c47a0dc219..fbd20f58ca 100644
--- a/lib/efi_loader/efi_memory.c
+++ b/lib/efi_loader/efi_memory.c
@@ -285,6 +285,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;
-- 
2.40.1
    
    
More information about the U-Boot
mailing list