Skip to contentSkip to conversation

efi_loader: Add check for fallback fdt memory reservation

PATCH Applied Alexander Graf 1 participant 2 messages Jul 3, 2017

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 efi_loader: Add check for fallback fdt memory reservation

When running bootefi, we allocate new space but never check whether the allocation succeeded. This patch adds a check so that in case things go wrong, we at least know they did.

---
 cmd/bootefi.c | 6 ++++++
 1 file changed, 6 insertions(+)
cmd/bootefi.c +6 -0
index a0a5434..771300e 100644
@@ -133,7 +133,13 @@ static void *copy_fdt(void *fdt)
 			       &new_fdt_addr) != EFI_SUCCESS) {
 		/* If we can't put it there, put it somewhere */
 		new_fdt_addr = (ulong)memalign(4096, fdt_size);
+		if (efi_allocate_pages(1, EFI_BOOT_SERVICES_DATA, fdt_pages,
+				       &new_fdt_addr) != EFI_SUCCESS) {
+			printf("ERROR: Failed to reserve space for FDT\n");
+			return NULL;
+		}
 	}
+
 	new_fdt = (void*)(ulong)new_fdt_addr;
 	memcpy(new_fdt, fdt, fdt_totalsize(fdt));
 	fdt_set_totalsize(new_fdt, fdt_size);
Signature · 1 line
1.8.5.6
author Applied
#1 lore raw
Quoted 5 lines

When running bootefi, we allocate new space but never check whether the allocation succeeded. This patch adds a check so that in case things go wrong, we at least know they did.

Thanks, applied to efi-next

Alex