]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
efi_loader: correct handling of EFI binary return code
authorHeinrich Schuchardt <heinrich.schuchardt@canonical.com>
Sat, 16 Mar 2024 09:36:42 +0000 (10:36 +0100)
committerHeinrich Schuchardt <heinrich.schuchardt@canonical.com>
Thu, 21 Mar 2024 06:28:43 +0000 (07:28 +0100)
We should not try to remove protocol interfaces from a NULL handle.
efi_run_image() should always return the return code of the executed EFI
binary.

Fixes: 6422820ac3e5 ("efi_loader: split unrelated code from efi_bootmgr.c")
Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
lib/efi_loader/efi_bootbin.c

index 733cc1a61b502055c5fa014495ef3235e26cac51..b7910f78fb6685ff32801e75640f2a630fbd9b2f 100644 (file)
@@ -125,7 +125,7 @@ efi_status_t efi_run_image(void *source_buffer, efi_uintn_t source_size)
        efi_handle_t mem_handle = NULL, handle;
        struct efi_device_path *file_path = NULL;
        struct efi_device_path *msg_path;
-       efi_status_t ret, ret2;
+       efi_status_t ret;
        u16 *load_options;
 
        if (!bootefi_device_path || !bootefi_image_path) {
@@ -172,11 +172,17 @@ efi_status_t efi_run_image(void *source_buffer, efi_uintn_t source_size)
        ret = do_bootefi_exec(handle, load_options);
 
 out:
-       ret2 = efi_uninstall_multiple_protocol_interfaces(mem_handle,
-                                                         &efi_guid_device_path,
-                                                         file_path, NULL);
+       if (mem_handle) {
+               efi_status_t r;
+
+               r = efi_uninstall_multiple_protocol_interfaces(
+                       mem_handle, &efi_guid_device_path, file_path, NULL);
+               if (r != EFI_SUCCESS)
+                       log_err("Uninstalling protocol interfaces failed\n");
+       }
        efi_free_pool(file_path);
-       return (ret != EFI_SUCCESS) ? ret : ret2;
+
+       return ret;
 }
 
 /**