[U-Boot] [PATCH 1/1] efi_loader: FreePages() must fail with pages = 0

Heinrich Schuchardt xypron.glpk at gmx.de
Thu Apr 25 17:21:30 UTC 2019


The UEFI spec requires that freeing of pages fails if the number of pages
to be freed is 'invalid'. Check that it is not zero.

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

diff --git a/lib/efi_loader/efi_memory.c b/lib/efi_loader/efi_memory.c
index 987cc6dc5f..776077cc35 100644
--- a/lib/efi_loader/efi_memory.c
+++ b/lib/efi_loader/efi_memory.c
@@ -452,7 +452,7 @@ efi_status_t efi_free_pages(uint64_t memory, efi_uintn_t pages)
 	uint64_t r = 0;

 	/* Sanity check */
-	if (!memory || (memory & EFI_PAGE_MASK)) {
+	if (!memory || (memory & EFI_PAGE_MASK) || !pages) {
 		printf("%s: illegal free 0x%llx, 0x%zx\n", __func__,
 		       memory, pages);
 		return EFI_INVALID_PARAMETER;
--
2.20.1



More information about the U-Boot mailing list