
The parent_handle of the loaded image must be set. Add the file path protocol from the provided parameter. Set system table. Add parameter checks.
Signed-off-by: Heinrich Schuchardt xypron.glpk@gmx.de --- lib/efi_loader/efi_boottime.c | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-)
diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c index c5a17b6252..477809e4ca 100644 --- a/lib/efi_loader/efi_boottime.c +++ b/lib/efi_loader/efi_boottime.c @@ -774,27 +774,54 @@ static efi_status_t EFIAPI efi_load_image(bool boot_policy, }; struct efi_loaded_image *info; struct efi_object *obj; + efi_status_t r;
EFI_ENTRY("%d, %p, %p, %p, %ld, %p", boot_policy, parent_image, file_path, source_buffer, source_size, image_handle); + + /* We do not support loading by device path, yet. */ + if (!source_buffer) { + r = EFI_NOT_FOUND; + goto out; + } + if (!parent_image || !image_handle) { + r = EFI_INVALID_PARAMETER; + goto out; + } + info = malloc(sizeof(*info)); + if (!info) { + r = EFI_OUT_OF_RESOURCES; + goto out; + } loaded_image_info_obj.protocols[0].protocol_interface = info; + loaded_image_info_obj.protocols[1].protocol_interface = file_path; obj = malloc(sizeof(loaded_image_info_obj)); + if (!obj) { + free(info); + r = EFI_OUT_OF_RESOURCES; + goto out; + } memset(info, 0, sizeof(*info)); memcpy(obj, &loaded_image_info_obj, sizeof(loaded_image_info_obj)); obj->handle = info; + info->system_table = &systab; + info->parent_handle = parent_image; info->file_path = file_path; info->reserved = efi_load_pe(source_buffer, info); if (!info->reserved) { free(info); free(obj); - return EFI_EXIT(EFI_UNSUPPORTED); + r = EFI_UNSUPPORTED; + goto out; }
*image_handle = info; list_add_tail(&obj->link, &efi_obj_list);
- return EFI_EXIT(EFI_SUCCESS); + r = EFI_SUCCESS; +out: + return EFI_EXIT(r); }
static efi_status_t EFIAPI efi_start_image(efi_handle_t image_handle,