
Checkpatch has errors on this. Please have a look
Also for some reason is fails to apply after patch 4.
Thanks /Ilias
On Thu, 12 Dec 2024 at 00:38, Simon Glass sjg@chromium.org wrote:
This code is only needed if an invalid image/device path is passed in. Move the code out to a caller where this can be dealt with. The normal flow will provide these parameters.
Signed-off-by: Simon Glass sjg@chromium.org
(no changes since v1)
lib/efi_loader/efi_bootbin.c | 103 ++++++++++++++++------------------- 1 file changed, 48 insertions(+), 55 deletions(-)
diff --git a/lib/efi_loader/efi_bootbin.c b/lib/efi_loader/efi_bootbin.c index 8ebd48547cb..582b2745ced 100644 --- a/lib/efi_loader/efi_bootbin.c +++ b/lib/efi_loader/efi_bootbin.c @@ -147,36 +147,13 @@ static efi_status_t efi_run_image(void *source_buffer, efi_uintn_t source_size, struct efi_device_path *device, struct efi_device_path *image) {
efi_handle_t mem_handle = NULL, handle;
struct efi_device_path *file_path = NULL;
struct efi_device_path *msg_path;
efi_handle_t handle;
struct efi_device_path *msg_path, *file_path; efi_status_t ret; u16 *load_options;
if (!device || !image) {
log_debug("Not loaded from disk\n");
/*
* Special case for efi payload not loaded from disk,
* such as 'bootefi hello' or for example payload
* loaded directly into memory via JTAG, etc:
*/
file_path = efi_dp_from_mem(EFI_RESERVED_MEMORY_TYPE,
source_buffer, source_size);
/*
* Make sure that device for device_path exist
* in load_image(). Otherwise, shell and grub will fail.
*/
ret = efi_install_multiple_protocol_interfaces(&mem_handle,
&efi_guid_device_path,
file_path, NULL);
if (ret != EFI_SUCCESS)
goto out;
msg_path = file_path;
} else {
file_path = efi_dp_concat(device, image, 0);
msg_path = image;
log_debug("Loaded from disk\n");
}
file_path = efi_dp_concat(device, image, 0);
msg_path = image; log_info("Booting %pD\n", msg_path);
@@ -195,36 +172,13 @@ static efi_status_t efi_run_image(void *source_buffer, efi_uintn_t source_size, ret = do_bootefi_exec(handle, load_options);
out:
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_binary_run_() - run loaded UEFI image
- @image_ptr: memory address of the UEFI image
- @size: size of the UEFI image
- @fdt: device-tree
- @device: EFI device-path
- @image: EFI image-path
- Execute an EFI binary image loaded at @image.
- @size may be zero if the binary is loaded with U-Boot load command.
- Return: status code
- */
-efi_status_t efi_binary_run_(void *image_ptr, size_t size, void *fdt,
struct efi_device_path *device,
struct efi_device_path *image)
+static efi_status_t efi_binary_run_(void *image_ptr, size_t size, void *fdt,
struct efi_device_path *device,
struct efi_device_path *image)
{ efi_status_t ret;
@@ -257,6 +211,45 @@ efi_status_t efi_binary_run_(void *image_ptr, size_t size, void *fdt, */ efi_status_t efi_binary_run(void *image, size_t size, void *fdt) {
return efi_binary_run_(image, size, fdt, bootefi_device_path,
bootefi_image_path);
efi_handle_t mem_handle = NULL;
struct efi_device_path *file_path = NULL;
efi_status_t ret;
if (!bootefi_device_path || !bootefi_image_path) {
log_debug("Not loaded from disk\n");
/*
* Special case for efi payload not loaded from disk,
* such as 'bootefi hello' or for example payload
* loaded directly into memory via JTAG, etc:
*/
file_path = efi_dp_from_mem(EFI_RESERVED_MEMORY_TYPE, image,
size);
/*
* Make sure that device for device_path exist
* in load_image(). Otherwise, shell and grub will fail.
*/
ret = efi_install_multiple_protocol_interfaces(&mem_handle,
&efi_guid_device_path,
file_path, NULL);
if (ret != EFI_SUCCESS)
goto out;
} else {
log_debug("Loaded from disk\n");
}
ret = efi_binary_run_(image, size, fdt, bootefi_device_path,
bootefi_image_path);
+out:
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;
}
-- 2.34.1