/**
* Set the load options of an image from an environment variable.
*
- * @handle: the image handle
- * @env_var: name of the environment variable
- * Return: status code
+ * @handle: the image handle
+ * @env_var: name of the environment variable
+ * @load_options: pointer to load options (output)
+ * Return: status code
*/
-static efi_status_t set_load_options(efi_handle_t handle, const char *env_var)
+static efi_status_t set_load_options(efi_handle_t handle, const char *env_var,
+ u16 **load_options)
{
struct efi_loaded_image *loaded_image_info;
size_t size;
u16 *pos;
efi_status_t ret;
+ *load_options = NULL;
ret = EFI_CALL(systab.boottime->open_protocol(
handle,
&efi_guid_loaded_image,
return EFI_OUT_OF_RESOURCES;
}
pos = loaded_image_info->load_options;
+ *load_options = pos;
utf8_utf16_strcpy(&pos, env);
loaded_image_info->load_options_size = size * 2;
efi_status_t ret;
efi_uintn_t exit_data_size = 0;
u16 *exit_data = NULL;
+ u16 *load_options;
/* Transfer environment variable as load options */
- ret = set_load_options(handle, "bootargs");
+ ret = set_load_options(handle, "bootargs", &load_options);
if (ret != EFI_SUCCESS)
return ret;
efi_restore_gd();
- /*
- * FIXME: Who is responsible for
- * free(loaded_image_info->load_options);
- * Once efi_exit() is implemented correctly,
- * handle itself doesn't exist here.
- */
+ free(load_options);
return ret;
}
struct efi_loaded_image **loaded_image_infop)
{
efi_status_t ret;
+ u16 *load_options;
ret = efi_setup_loaded_image(device_path, image_path, image_objp,
loaded_image_infop);
return ret;
/* Transfer environment variable as load options */
- return set_load_options((efi_handle_t)*image_objp, load_options_path);
+ return set_load_options((efi_handle_t)*image_objp, load_options_path,
+ &load_options);
}
/**