From 562c406763d6c078ccf9fad1058e6d618b2456da Mon Sep 17 00:00:00 2001 From: Michael Chang Date: Mon, 19 Dec 2016 17:09:04 +0800 Subject: [PATCH] Fix fwpath in efi netboot The path returned by grub_efi_net_config has already been stripped for the directory part extracted from cached bootp packet. We should just return the result to avoild it be stripped again. It fixed the problem that grub.efi as NBP image always looking for grub.cfg and platform directory in upper folder rather than current one it gets loaded while $prefix is empty. The behavior is inconsistent with other architecture and how we would expect empty $prefix going to be in general. The only exception to the general rule of empty $prefix is that when loaded from platform directory itself, the platform part is stripped thus upper folder is used for looking up files. It meets the case for how grub-mknetdir lay out the files under tftp root directory, but also hide away this issue to be identified as it appears to be just works. Also fix possible memory leak by moving grub_efi_get_filename() call after grub_efi_net_config(). --- grub-core/kern/efi/init.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/grub-core/kern/efi/init.c b/grub-core/kern/efi/init.c index e9c85de12..2c31847bf 100644 --- a/grub-core/kern/efi/init.c +++ b/grub-core/kern/efi/init.c @@ -59,10 +59,13 @@ grub_machine_get_bootlocation (char **device, char **path) if (!image) return; *device = grub_efidisk_get_device_name (image->device_handle); - *path = grub_efi_get_filename (image->file_path); if (!*device && grub_efi_net_config) - grub_efi_net_config (image->device_handle, device, path); + { + grub_efi_net_config (image->device_handle, device, path); + return; + } + *path = grub_efi_get_filename (image->file_path); if (*path) { /* Get the directory. */