efi: Do not panic if GetMemoryMap() fails after first ExitBootServices()

This commit is contained in:
mintsuki 2022-04-15 18:37:17 +02:00
parent 40cbbe5dcb
commit 0e1e88aa37

View File

@ -184,19 +184,22 @@ bool efi_exit_boot_services(void) {
efi_mmap_size += 4096; efi_mmap_size += 4096;
status = gBS->FreePool(efi_mmap); status = gBS->FreePool(efi_mmap);
if (status) if (status) {
goto fail; goto fail;
}
status = gBS->AllocatePool(EfiLoaderData, efi_mmap_size, (void **)&efi_mmap); status = gBS->AllocatePool(EfiLoaderData, efi_mmap_size, (void **)&efi_mmap);
if (status) if (status) {
goto fail; goto fail;
}
size_t retries = 0; size_t retries = 0;
retry: retry:
status = gBS->GetMemoryMap(&efi_mmap_size, efi_mmap, &mmap_key, &efi_desc_size, &efi_desc_ver); status = gBS->GetMemoryMap(&efi_mmap_size, efi_mmap, &mmap_key, &efi_desc_size, &efi_desc_ver);
if (status) if (retries == 0 && status) {
goto fail; goto fail;
}
// Be gone, UEFI! // Be gone, UEFI!
status = gBS->ExitBootServices(efi_image_handle, mmap_key); status = gBS->ExitBootServices(efi_image_handle, mmap_key);