]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
efi_loader: do not install dtb if bootmgr fails
authorHeinrich Schuchardt <heinrich.schuchardt@canonical.com>
Mon, 22 Apr 2024 09:03:10 +0000 (11:03 +0200)
committerHeinrich Schuchardt <heinrich.schuchardt@canonical.com>
Wed, 1 May 2024 05:39:00 +0000 (07:39 +0200)
If the UEFI boot manager fails there is no point in installing the
device-tree as a configuration table.

Unload image if device-tree cannot be installed.

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
lib/efi_loader/efi_bootmgr.c

index ca2ebdaa32f76ab4f62cb930cb263cbd03b608d6..7da3139f9177e76dc7944bfdc69120335c0222d1 100644 (file)
@@ -1209,15 +1209,21 @@ efi_status_t efi_bootmgr_run(void *fdt)
                return CMD_RET_FAILURE;
        }
 
-       ret = efi_install_fdt(fdt);
-       if (ret != EFI_SUCCESS)
-               return ret;
-
        ret = efi_bootmgr_load(&handle, &load_options);
        if (ret != EFI_SUCCESS) {
                log_notice("EFI boot manager: Cannot load any image\n");
                return ret;
        }
 
+       ret = efi_install_fdt(fdt);
+       if (ret != EFI_SUCCESS) {
+               if (EFI_CALL(efi_unload_image(handle)) == EFI_SUCCESS)
+                       free(load_options);
+               else
+                       log_err("Unloading image failed\n");
+
+               return ret;
+       }
+
        return do_bootefi_exec(handle, load_options);
 }