summaryrefslogtreecommitdiff
path: root/cmd/bootefi.c
diff options
context:
space:
mode:
authorAlexander Graf <agraf@suse.de>2017-07-03 13:32:35 +0200
committerAlexander Graf <agraf@suse.de>2017-07-03 13:35:47 +0200
commit85a6e9b3c9d16ec062a6da3129448f39aad94fc9 (patch)
tree41493e428f1938753e78541648276ec124281106 /cmd/bootefi.c
parent8d6040c725bfa40fba1bd6b5f356ee713c1ac7d1 (diff)
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. Signed-off-by: Alexander Graf <agraf@suse.de>
Diffstat (limited to 'cmd/bootefi.c')
-rw-r--r--cmd/bootefi.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/cmd/bootefi.c b/cmd/bootefi.c
index a0a5434967..771300ee94 100644
--- a/cmd/bootefi.c
+++ b/cmd/bootefi.c
@@ -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);