grub-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH v2 09/12] efi: Print error messages to grub_efi_allocate_pages_re


From: Javier Martinez Canillas
Subject: [PATCH v2 09/12] efi: Print error messages to grub_efi_allocate_pages_real()
Date: Wed, 4 Mar 2020 12:58:48 +0100

From: Peter Jones <address@hidden>

No messages were printed in this function, add some to ease debugging.

Also, the function returns a void * pointer so return NULL instead of
0 to make the code more readable.

Signed-off-by: Peter Jones <address@hidden>
Signed-off-by: Javier Martinez Canillas <address@hidden>
---

 grub-core/kern/efi/mm.c | 17 ++++++++++++++---
 1 file changed, 14 insertions(+), 3 deletions(-)

diff --git a/grub-core/kern/efi/mm.c b/grub-core/kern/efi/mm.c
index b02fab1b102..457772d57f2 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);
-- 
2.24.1




reply via email to

[Prev in Thread] Current Thread [Next in Thread]