[U-Boot] [PATCH 2/4] efi_loader: check parameters in memory allocation

Heinrich Schuchardt xypron.glpk at gmx.de
Mon Jul 2 10:53:53 UTC 2018


If no pointer is provided throw an error.

Signed-off-by: Heinrich Schuchardt <xypron.glpk at gmx.de>
---
 lib/efi_loader/efi_memory.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/lib/efi_loader/efi_memory.c b/lib/efi_loader/efi_memory.c
index 86edfc95f4..f5aecd4b41 100644
--- a/lib/efi_loader/efi_memory.c
+++ b/lib/efi_loader/efi_memory.c
@@ -293,6 +293,9 @@ efi_status_t efi_allocate_pages(int type, int memory_type,
 	efi_status_t r = EFI_SUCCESS;
 	uint64_t addr;
 
+	if (!memory)
+		return EFI_INVALID_PARAMETER;
+
 	switch (type) {
 	case EFI_ALLOCATE_ANY_PAGES:
 		/* Any page */
@@ -386,6 +389,9 @@ efi_status_t efi_allocate_pool(int pool_type, efi_uintn_t size, void **buffer)
 	u64 num_pages = (size + sizeof(struct efi_pool_allocation) +
 			 EFI_PAGE_MASK) >> EFI_PAGE_SHIFT;
 
+	if (!buffer)
+		return EFI_INVALID_PARAMETER;
+
 	if (size == 0) {
 		*buffer = NULL;
 		return EFI_SUCCESS;
-- 
2.18.0



More information about the U-Boot mailing list