From: AKASHI Takahiro Date: Tue, 21 Nov 2023 01:29:43 +0000 (+0900) Subject: cmd: bootefi: localize global device paths for efi_selftest X-Git-Url: http://git.dujemihanovic.xyz/?a=commitdiff_plain;h=d07e7be7ea4b35960730661c130dea5234d38101;p=u-boot.git cmd: bootefi: localize global device paths for efi_selftest 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 --- diff --git a/cmd/bootefi.c b/cmd/bootefi.c index 83f28e0bc7..69977b2af0 100644 --- a/cmd/bootefi.c +++ b/cmd/bootefi.c @@ -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