
On 11/15/18 12:11 AM, Simon Glass wrote:
This function can be used from do_bootefi_exec() so that we use mostly the same code for a normal EFI application and an EFI test.
Rename the function and use it in both places.
Signed-off-by: Simon Glass sjg@chromium.org
Changes in v14:
- Go back to the horrible long variable names
- Hopefully correct error paths in do_bootefi_exec()
Changes in v13:
- Drop 'efi_loader: Drop setup_ok' as we have an existing patch for that
- Drop patches previously applied
Changes in v12: None Changes in v11:
- Drop patches previously applied
Changes in v9: None Changes in v7:
- Drop patch "efi: Init the 'rows' and 'cols' variables"
- Drop patches previous applied
Changes in v5:
- Rebase to master
Changes in v4:
- Rebase to master
Changes in v3:
- Add new patch to rename bootefi_test_finish() to bootefi_run_finish()
cmd/bootefi.c | 46 ++++++++++++++++++++++++---------------------- 1 file changed, 24 insertions(+), 22 deletions(-)
diff --git a/cmd/bootefi.c b/cmd/bootefi.c index ab7ada9f2d6..a627f689f95 100644 --- a/cmd/bootefi.c +++ b/cmd/bootefi.c @@ -350,6 +350,20 @@ static efi_status_t bootefi_run_prepare(const char *load_options_path, return 0; }
+/**
- bootefi_run_finish() - finish up after running an EFI test
- @loaded_image_info: Pointer to a struct which holds the loaded image info
- @image_objj: Pointer to a struct which holds the loaded image object
- */
+static void bootefi_run_finish(struct efi_loaded_image_obj *image_obj,
struct efi_loaded_image *loaded_image_info)
+{
- efi_restore_gd();
- free(loaded_image_info->load_options);
- efi_delete_handle(&image_obj->header);
+}
/**
- do_bootefi_exec() - execute EFI binary
@@ -390,11 +404,11 @@ static efi_status_t do_bootefi_exec(void *efi, */ ret = efi_create_handle(&mem_handle); if (ret != EFI_SUCCESS)
goto exit;
You are leaking a device path.
Best regards
Heinrich
ret = efi_add_protocol(mem_handle, &efi_guid_device_path, device_path); if (ret != EFI_SUCCESS)return ret;
goto exit;
} else { assert(device_path && image_path); }goto err_add_protocol;
@@ -402,13 +416,13 @@ static efi_status_t do_bootefi_exec(void *efi, ret = bootefi_run_prepare("bootargs", device_path, image_path, &image_obj, &loaded_image_info); if (ret)
return ret;
goto err_prepare;
/* Load the EFI payload */ entry = efi_load_pe(image_obj, efi, loaded_image_info); if (!entry) { ret = EFI_LOAD_ERROR;
goto exit;
goto err_prepare;
}
if (memdp) {
@@ -428,7 +442,7 @@ static efi_status_t do_bootefi_exec(void *efi,
if (setjmp(&image_obj->exit_jmp)) { ret = image_obj->exit_status;
goto exit;
}goto err_prepare;
#ifdef CONFIG_ARM64 @@ -466,10 +480,11 @@ static efi_status_t do_bootefi_exec(void *efi,
ret = efi_do_enter(&image_obj->header, &systab, entry);
-exit: +err_prepare: /* image has returned, loaded-image obj goes *poof*: */
- if (image_obj)
efi_delete_handle(&image_obj->header);
- bootefi_run_finish(image_obj, loaded_image_info);
+err_add_protocol: if (mem_handle) efi_delete_handle(mem_handle);
@@ -510,19 +525,6 @@ static efi_status_t bootefi_test_prepare( loaded_image_infop); }
-/**
- bootefi_test_finish() - finish up after running an EFI test
- @image_obj: Pointer to a struct which holds the loaded image object
- @loaded_image_info: Pointer to a struct which holds the loaded image info
- */
-static void bootefi_test_finish(struct efi_loaded_image_obj *image_obj,
struct efi_loaded_image *loaded_image_info)
-{
- efi_restore_gd();
- free(loaded_image_info->load_options);
- efi_delete_handle(&image_obj->header);
-} #endif /* CONFIG_CMD_BOOTEFI_SELFTEST */
static int do_bootefi_bootmgr_exec(void) @@ -607,7 +609,7 @@ static int do_bootefi(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
/* Execute the test */ r = efi_selftest(&image_obj->header, &systab);
bootefi_test_finish(image_obj, loaded_image_info);
return r != EFI_SUCCESS; } elsebootefi_run_finish(image_obj, loaded_image_info);
#endif