Skip to content

Commit

Permalink
Fallback to default loader if parsed one does not exist
Browse files Browse the repository at this point in the history
If the specified second stage loader does not exist (invalid
parameter), fall back to the DEFAULT_LOADER. This avoids failing
the boot on any garbage that made it through the load option parser
as a second stage loader name.

Bug-Ubuntu: https://bugs.launchpad.net/bugs/1937115
  • Loading branch information
julian-klode authored and vathpela committed Sep 14, 2021
1 parent 11740ea commit 50732ee
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions shim.c
Original file line number Diff line number Diff line change
Expand Up @@ -1116,6 +1116,19 @@ EFI_STATUS init_grub(EFI_HANDLE image_handle)
use_fb ? FALLBACK : second_stage);
}

// If the filename is invalid, or the file does not exist,
// just fallback to the default loader.
if (!use_fb && (efi_status == EFI_INVALID_PARAMETER ||
efi_status == EFI_NOT_FOUND)) {
console_print(
L"start_image() returned %r, falling back to default loader\n",
efi_status);
msleep(2000000);
load_options = NULL;
load_options_size = 0;
efi_status = start_image(image_handle, DEFAULT_LOADER);
}

if (EFI_ERROR(efi_status)) {
console_print(L"start_image() returned %r\n", efi_status);
msleep(2000000);
Expand Down

0 comments on commit 50732ee

Please sign in to comment.