|
|
8e15ce |
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
|
8e15ce |
From: Peter Jones <pjones@redhat.com>
|
|
|
8e15ce |
Date: Thu, 1 Jun 2017 10:06:38 -0400
|
|
|
8e15ce |
Subject: [PATCH] Use grub_efi_...() memory helpers where reasonable.
|
|
|
8e15ce |
|
|
|
8e15ce |
This uses grub_efi_allocate_pool(), grub_efi_free_pool(), and
|
|
|
8e15ce |
grub_efi_free_pages() instead of open-coded efi_call_N() calls, so we
|
|
|
8e15ce |
get more reasonable type checking.
|
|
|
8e15ce |
|
|
|
8e15ce |
Signed-off-by: Peter Jones <pjones@redhat.com>
|
|
|
8e15ce |
---
|
|
|
8e15ce |
grub-core/loader/efi/chainloader.c | 24 +++++++++---------------
|
|
|
8e15ce |
1 file changed, 9 insertions(+), 15 deletions(-)
|
|
|
8e15ce |
|
|
|
8e15ce |
diff --git a/grub-core/loader/efi/chainloader.c b/grub-core/loader/efi/chainloader.c
|
|
|
b35c50 |
index 07c4937898..89ac84cc66 100644
|
|
|
8e15ce |
--- a/grub-core/loader/efi/chainloader.c
|
|
|
8e15ce |
+++ b/grub-core/loader/efi/chainloader.c
|
|
|
8e15ce |
@@ -65,7 +65,7 @@ grub_chainloader_unload (void)
|
|
|
8e15ce |
|
|
|
8e15ce |
b = grub_efi_system_table->boot_services;
|
|
|
8e15ce |
efi_call_1 (b->unload_image, image_handle);
|
|
|
8e15ce |
- efi_call_2 (b->free_pages, address, pages);
|
|
|
8e15ce |
+ grub_efi_free_pages (address, pages);
|
|
|
8e15ce |
|
|
|
8e15ce |
grub_free (file_path);
|
|
|
8e15ce |
grub_free (cmdline);
|
|
|
8e15ce |
@@ -108,7 +108,7 @@ grub_chainloader_boot (void)
|
|
|
8e15ce |
}
|
|
|
8e15ce |
|
|
|
8e15ce |
if (exit_data)
|
|
|
8e15ce |
- efi_call_1 (b->free_pool, exit_data);
|
|
|
8e15ce |
+ grub_efi_free_pool (exit_data);
|
|
|
8e15ce |
|
|
|
8e15ce |
grub_loader_unset ();
|
|
|
8e15ce |
|
|
|
b35c50 |
@@ -527,10 +527,9 @@ grub_efi_get_media_file_path (grub_efi_device_path_t *dp)
|
|
|
8e15ce |
static grub_efi_boolean_t
|
|
|
8e15ce |
handle_image (void *data, grub_efi_uint32_t datasize)
|
|
|
8e15ce |
{
|
|
|
8e15ce |
- grub_efi_boot_services_t *b;
|
|
|
8e15ce |
grub_efi_loaded_image_t *li, li_bak;
|
|
|
8e15ce |
grub_efi_status_t efi_status;
|
|
|
8e15ce |
- char *buffer = NULL;
|
|
|
8e15ce |
+ void *buffer = NULL;
|
|
|
8e15ce |
char *buffer_aligned = NULL;
|
|
|
8e15ce |
grub_efi_uint32_t i;
|
|
|
8e15ce |
struct grub_pe32_section_table *section;
|
|
|
b35c50 |
@@ -541,8 +540,6 @@ handle_image (void *data, grub_efi_uint32_t datasize)
|
|
|
8e15ce |
int found_entry_point = 0;
|
|
|
8e15ce |
int rc;
|
|
|
8e15ce |
|
|
|
8e15ce |
- b = grub_efi_system_table->boot_services;
|
|
|
8e15ce |
-
|
|
|
8e15ce |
rc = read_header (data, datasize, &context);
|
|
|
8e15ce |
if (rc < 0)
|
|
|
8e15ce |
{
|
|
|
b35c50 |
@@ -582,8 +579,8 @@ handle_image (void *data, grub_efi_uint32_t datasize)
|
|
|
8e15ce |
grub_dprintf ("chain", "image size is %08"PRIxGRUB_UINT64_T", datasize is %08x\n",
|
|
|
8e15ce |
context.image_size, datasize);
|
|
|
8e15ce |
|
|
|
8e15ce |
- efi_status = efi_call_3 (b->allocate_pool, GRUB_EFI_LOADER_DATA,
|
|
|
8e15ce |
- buffer_size, &buffer);
|
|
|
8e15ce |
+ efi_status = grub_efi_allocate_pool (GRUB_EFI_LOADER_DATA, buffer_size,
|
|
|
8e15ce |
+ &buffer);
|
|
|
8e15ce |
|
|
|
8e15ce |
if (efi_status != GRUB_EFI_SUCCESS)
|
|
|
8e15ce |
{
|
|
|
b35c50 |
@@ -815,14 +812,14 @@ handle_image (void *data, grub_efi_uint32_t datasize)
|
|
|
8e15ce |
|
|
|
8e15ce |
grub_dprintf ("chain", "entry_point returned %ld\n", efi_status);
|
|
|
8e15ce |
grub_memcpy (li, &li_bak, sizeof (grub_efi_loaded_image_t));
|
|
|
8e15ce |
- efi_status = efi_call_1 (b->free_pool, buffer);
|
|
|
8e15ce |
+ efi_status = grub_efi_free_pool (buffer);
|
|
|
8e15ce |
|
|
|
8e15ce |
return 1;
|
|
|
8e15ce |
|
|
|
8e15ce |
error_exit:
|
|
|
8e15ce |
grub_dprintf ("chain", "error_exit: grub_errno: %d\n", grub_errno);
|
|
|
8e15ce |
if (buffer)
|
|
|
8e15ce |
- efi_call_1 (b->free_pool, buffer);
|
|
|
8e15ce |
+ grub_efi_free_pool (buffer);
|
|
|
8e15ce |
|
|
|
8e15ce |
return 0;
|
|
|
8e15ce |
}
|
|
|
b35c50 |
@@ -830,10 +827,7 @@ error_exit:
|
|
|
8e15ce |
static grub_err_t
|
|
|
8e15ce |
grub_secureboot_chainloader_unload (void)
|
|
|
8e15ce |
{
|
|
|
8e15ce |
- grub_efi_boot_services_t *b;
|
|
|
8e15ce |
-
|
|
|
8e15ce |
- b = grub_efi_system_table->boot_services;
|
|
|
8e15ce |
- efi_call_2 (b->free_pages, address, pages);
|
|
|
8e15ce |
+ grub_efi_free_pages (address, pages);
|
|
|
8e15ce |
grub_free (file_path);
|
|
|
8e15ce |
grub_free (cmdline);
|
|
|
8e15ce |
cmdline = 0;
|
|
|
b35c50 |
@@ -1100,7 +1094,7 @@ fail:
|
|
|
8e15ce |
grub_free (file_path);
|
|
|
8e15ce |
|
|
|
8e15ce |
if (address)
|
|
|
8e15ce |
- efi_call_2 (b->free_pages, address, pages);
|
|
|
8e15ce |
+ grub_efi_free_pages (address, pages);
|
|
|
8e15ce |
|
|
|
8e15ce |
if (cmdline)
|
|
|
8e15ce |
grub_free (cmdline);
|