]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
cmd: bootefi: localize global device paths for efi_selftest
authorAKASHI Takahiro <takahiro.akashi@linaro.org>
Tue, 21 Nov 2023 01:29:43 +0000 (10:29 +0900)
committerHeinrich Schuchardt <heinrich.schuchardt@canonical.com>
Sun, 17 Dec 2023 12:04:54 +0000 (13:04 +0100)
Device paths allocated in bootefi_test_prepare() will be immediately
consumed by do_efi_selftest() and there is no need to keep them for later
use. Introduce test-specific varialbles to make it easier to move other
bootmgr functions into library directory in the next commit.

Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
cmd/bootefi.c

index 83f28e0bc71018e4ef0ae5d5cfa5c0521b37c06e..69977b2af0ee0c8c3b120fafaae717ea3db49ce0 100644 (file)
@@ -29,6 +29,8 @@
 
 DECLARE_GLOBAL_DATA_PTR;
 
+static struct efi_device_path *test_image_path;
+static struct efi_device_path *test_device_path;
 static struct efi_device_path *bootefi_image_path;
 static struct efi_device_path *bootefi_device_path;
 static void *image_addr;
@@ -586,23 +588,26 @@ static efi_status_t bootefi_test_prepare
        efi_status_t ret;
 
        /* Construct a dummy device path */
-       bootefi_device_path = efi_dp_from_mem(EFI_RESERVED_MEMORY_TYPE, 0, 0);
-       if (!bootefi_device_path)
+       test_device_path = efi_dp_from_mem(EFI_RESERVED_MEMORY_TYPE, 0, 0);
+       if (!test_device_path)
                return EFI_OUT_OF_RESOURCES;
 
-       bootefi_image_path = efi_dp_from_file(NULL, path);
-       if (!bootefi_image_path) {
+       test_image_path = efi_dp_from_file(NULL, path);
+       if (!test_image_path) {
                ret = EFI_OUT_OF_RESOURCES;
                goto failure;
        }
 
-       ret = bootefi_run_prepare(load_options_path, bootefi_device_path,
-                                 bootefi_image_path, image_objp,
+       ret = bootefi_run_prepare(load_options_path, test_device_path,
+                                 test_image_path, image_objp,
                                  loaded_image_infop);
        if (ret == EFI_SUCCESS)
                return ret;
 
 failure:
+       efi_free_pool(test_device_path);
+       efi_free_pool(test_image_path);
+       /* TODO: not sure calling clear function is necessary */
        efi_clear_bootdev();
        return ret;
 }
@@ -627,6 +632,8 @@ static int do_efi_selftest(void)
        ret = EFI_CALL(efi_selftest(&image_obj->header, &systab));
        efi_restore_gd();
        free(loaded_image_info->load_options);
+       efi_free_pool(test_device_path);
+       efi_free_pool(test_image_path);
        if (ret != EFI_SUCCESS)
                efi_delete_handle(&image_obj->header);
        else