From c2b23e972b657cdb5e0794c93d342f167fffb3e3 Mon Sep 17 00:00:00 2001 From: Ricardo Neri Date: Fri, 27 Mar 2015 08:31:27 -0700 Subject: [PATCH 7/7] efi: chainloader: take care of unload undershim Upstream-Status: Inappropriate [embedded specific] Under shim, we use a custom buffer to put the relocated image, make sure we free that memory when unloading. Signed-off-by: Ricardo Neri --- grub-core/loader/efi/chainloader.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/grub-core/loader/efi/chainloader.c b/grub-core/loader/efi/chainloader.c index baa85be..7b733a7 100644 --- a/grub-core/loader/efi/chainloader.c +++ b/grub-core/loader/efi/chainloader.c @@ -590,7 +590,17 @@ grub_chainloader_unload (void *context) grub_free (loaded_image->load_options); b = grub_efi_system_table->boot_services; - efi_call_1 (b->unload_image, image_handle); + if (!shim_used) + { + efi_call_1 (b->unload_image, image_handle); + } + else + { + if (shim_buffer) + { + efi_call_2 (b->free_pages, shim_buffer, shim_pages); + } + } grub_dl_unref (my_mod); return GRUB_ERR_NONE; -- 2.25.1