U-Boot Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Ilias Apalodimas <ilias.apalodimas@linaro.org>
To: Masahisa Kojima <masahisa.kojima@linaro.org>
Cc: u-boot@lists.denx.de, Heinrich Schuchardt <xypron.glpk@gmx.de>,
	Simon Glass <sjg@chromium.org>,
	Takahiro Akashi <takahiro.akashi@linaro.org>,
	Mark Kettenis <mark.kettenis@xs4all.nl>
Subject: Re: [PATCH v13 5/9] bootmenu: add removable media entries
Date: Wed, 24 Aug 2022 17:17:39 +0300	[thread overview]
Message-ID: <YwYzA21cXSxOapHJ@hades> (raw)
In-Reply-To: <20220824063740.5760-6-masahisa.kojima@linaro.org>

Hi Kojima-san,

Apologies for doing the review ad-hoc, but the patchset is huge. 
I'll try to send a more complete email tomorrow

[...]
>  #endif
>  
> diff --git a/cmd/eficonfig.c b/cmd/eficonfig.c
> index 537f3f2bbc..92171c4894 100644
> --- a/cmd/eficonfig.c
> +++ b/cmd/eficonfig.c
> @@ -1786,6 +1786,215 @@ static efi_status_t eficonfig_process_delete_boot_option(void *data)
>  	return ret;
>  }
>  
> +/**
> + * eficonfig_enumerate_boot_option() - enumerate the possible bootable media
> + *
> + * @opt:		pointer to the media boot option structure
> + * @volume_handles:	pointer to the efi handles
> + * @count:		number of efi handle
> + * Return:		status code
> + */
> +efi_status_t eficonfig_enumerate_boot_option(struct eficonfig_media_boot_option *opt,
> +					     efi_handle_t *volume_handles, efi_status_t count)
> +{
> +	u32 i;
> +	struct efi_handler *handler;
> +	efi_status_t ret = EFI_SUCCESS;
> +
> +	for (i = 0; i < count; i++) {
> +		u16 *p;
> +		u16 dev_name[BOOTMENU_DEVICE_NAME_MAX];
> +		char *optional_data;
> +		struct efi_load_option lo;
> +		char buf[BOOTMENU_DEVICE_NAME_MAX];
> +		struct efi_device_path *device_path;
> +
> +		ret = efi_search_protocol(volume_handles[i], &efi_guid_device_path, &handler);
> +		if (ret != EFI_SUCCESS)
> +			continue;
> +		ret = efi_protocol_open(handler, (void **)&device_path,
> +					efi_root, NULL, EFI_OPEN_PROTOCOL_GET_PROTOCOL);
> +		if (ret != EFI_SUCCESS)
> +			continue;
> +
> +		ret = efi_disk_get_device_name(volume_handles[i], buf, BOOTMENU_DEVICE_NAME_MAX);
> +		if (ret != EFI_SUCCESS)
> +			continue;
> +
> +		p = dev_name;
> +		utf8_utf16_strncpy(&p, buf, strlen(buf));
> +
> +		lo.label = dev_name;
> +		lo.attributes = LOAD_OPTION_ACTIVE;
> +		lo.file_path = device_path;
> +		lo.file_path_length = efi_dp_size(device_path) + sizeof(END);
> +		/*
> +		 * Set the dedicated guid to optional_data, it is used to identify
> +		 * the boot option that automatically generated by the bootmenu.
> +		 * efi_serialize_load_option() expects optional_data is null-terminated
> +		 * utf8 string, so set the "1234567" string to allocate enough space
> +		 * to store guid, instead of realloc the load_option.
> +		 */
> +		lo.optional_data = "1234567";
> +		opt[i].size = efi_serialize_load_option(&lo, (u8 **)&opt[i].lo);
> +		if (!opt[i].size) {
> +			ret = EFI_OUT_OF_RESOURCES;
> +			free(dev_name);

This is a stack allocated variable.

> +			goto out;
> +		}
> +		/* set the guid */

[...]

Thanks
/Ilias

  parent reply	other threads:[~2022-08-24 14:17 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-24  6:37 [PATCH v13 0/9] enable menu-driven UEFI variable maintenance Masahisa Kojima
2022-08-24  6:37 ` [PATCH v13 1/9] eficonfig: menu-driven addition of UEFI boot option Masahisa Kojima
2022-08-24 11:15   ` Ilias Apalodimas
2022-08-25  3:16     ` Masahisa Kojima
2022-08-24 14:19   ` Ilias Apalodimas
2022-08-25  3:17     ` Masahisa Kojima
2022-08-24  6:37 ` [PATCH v13 2/9] eficonfig: add "Edit Boot Option" menu entry Masahisa Kojima
2022-08-24  6:37 ` [PATCH v13 3/9] menu: add KEY_PLUS, KEY_MINUS and KEY_SPACE handling Masahisa Kojima
2022-08-24  6:37 ` [PATCH v13 4/9] eficonfig: add "Delete Boot Option" menu entry Masahisa Kojima
2022-08-24  6:37 ` [PATCH v13 5/9] bootmenu: add removable media entries Masahisa Kojima
2022-08-24 13:25   ` Ilias Apalodimas
2022-08-25  3:25     ` Masahisa Kojima
2022-08-25  8:03       ` Ilias Apalodimas
2022-08-25  8:26         ` Masahisa Kojima
2022-08-24 14:17   ` Ilias Apalodimas [this message]
2022-08-25  3:27     ` Masahisa Kojima
2022-08-24  6:37 ` [PATCH v13 6/9] eficonfig: add "Change Boot Order" menu entry Masahisa Kojima
2022-08-25  0:11   ` Takahiro Akashi
2022-08-25  2:36     ` Masahisa Kojima
2022-08-24  6:37 ` [PATCH v13 7/9] doc:bootmenu: add description for UEFI boot support Masahisa Kojima
2022-08-24  6:37 ` [PATCH v13 8/9] doc:eficonfig: add documentation for eficonfig command Masahisa Kojima
2022-08-24  9:13   ` Ilias Apalodimas
2022-08-25  2:11     ` Masahisa Kojima
2022-08-24  6:37 ` [PATCH v13 9/9] test: unit test for eficonfig Masahisa Kojima
2022-08-24  9:09   ` Ilias Apalodimas

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YwYzA21cXSxOapHJ@hades \
    --to=ilias.apalodimas@linaro.org \
    --cc=mark.kettenis@xs4all.nl \
    --cc=masahisa.kojima@linaro.org \
    --cc=sjg@chromium.org \
    --cc=takahiro.akashi@linaro.org \
    --cc=u-boot@lists.denx.de \
    --cc=xypron.glpk@gmx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox