diff --git a/grub-core/kern/efi/mm.c b/grub-core/kern/efi/mm.c index b02fab1b1..457772d57 100644 --- a/grub-core/kern/efi/mm.c +++ b/grub-core/kern/efi/mm.c @@ -125,12 +125,20 @@ grub_efi_allocate_pages_real (grub_efi_physical_address_t address, /* Limit the memory access to less than 4GB for 32-bit platforms. */ if (address > GRUB_EFI_MAX_USABLE_ADDRESS) - return 0; + { + grub_error (GRUB_ERR_BAD_ARGUMENT, + N_("invalid memory address (0x%llx > 0x%llx)"), + address, GRUB_EFI_MAX_USABLE_ADDRESS); + return NULL; + } b = grub_efi_system_table->boot_services; status = efi_call_4 (b->allocate_pages, alloctype, memtype, pages, &address); if (status != GRUB_EFI_SUCCESS) - return 0; + { + grub_error (GRUB_ERR_OUT_OF_MEMORY, N_("out of memory")); + return NULL; + } if (address == 0) { @@ -140,7 +148,10 @@ grub_efi_allocate_pages_real (grub_efi_physical_address_t address, status = efi_call_4 (b->allocate_pages, alloctype, memtype, pages, &address); grub_efi_free_pages (0, pages); if (status != GRUB_EFI_SUCCESS) - return 0; + { + grub_error (GRUB_ERR_OUT_OF_MEMORY, N_("out of memory")); + return NULL; + } } grub_efi_store_alloc (address, pages);