Correct EFI chainloader image device path (#2397)

This commit is contained in:
A1ive 2023-05-19 23:23:14 +08:00 committed by GitHub
parent 82053680bf
commit 35c952d891
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 15 deletions

View File

@ -229,10 +229,7 @@ grub_cmd_chainloader (grub_command_t cmd __attribute__ ((unused)),
if (! file) if (! file)
goto fail; goto fail;
/* Get the root device's device path. */ dev = file->device;
dev = grub_device_open (0);
if (! dev)
goto fail;
if (dev->disk) if (dev->disk)
dev_handle = grub_efidisk_get_device_handle (dev->disk); dev_handle = grub_efidisk_get_device_handle (dev->disk);
@ -257,15 +254,12 @@ grub_cmd_chainloader (grub_command_t cmd __attribute__ ((unused)),
if (dev_handle) if (dev_handle)
dp = grub_efi_get_device_path (dev_handle); dp = grub_efi_get_device_path (dev_handle);
if (! dp) if (dp != NULL)
{ {
grub_error (GRUB_ERR_BAD_DEVICE, "not a valid root device");
goto fail;
}
file_path = make_file_path (dp, filename); file_path = make_file_path (dp, filename);
if (! file_path) if (! file_path)
goto fail; goto fail;
}
//grub_printf ("file path: "); //grub_printf ("file path: ");
//grub_efi_print_device_path (file_path); //grub_efi_print_device_path (file_path);
@ -390,16 +384,12 @@ grub_cmd_chainloader (grub_command_t cmd __attribute__ ((unused)),
} }
grub_file_close (file); grub_file_close (file);
grub_device_close (dev);
grub_loader_set (grub_chainloader_boot, grub_chainloader_unload, 0); grub_loader_set (grub_chainloader_boot, grub_chainloader_unload, 0);
return 0; return 0;
fail: fail:
if (dev)
grub_device_close (dev);
if (file) if (file)
grub_file_close (file); grub_file_close (file);