All of lore.kernel.org
 help / color / mirror / Atom feed
From: Heinrich Schuchardt <xypron.glpk@gmx.de>
To: u-boot@lists.denx.de
Subject: [PATCH v10 02/11] efi_loader: capsule: add capsule_on_disk support
Date: Wed, 17 Mar 2021 22:02:54 +0100	[thread overview]
Message-ID: <ff23d85d-7bd5-8c4d-5e33-c3e805318d22@gmx.de> (raw)
In-Reply-To: <20201130091218.66413-3-takahiro.akashi@linaro.org>

On 11/30/20 10:12 AM, AKASHI Takahiro wrote:
> Capsule data can be loaded into the system either via UpdateCapsule
> runtime service or files on a file system (of boot device).
> The latter case is called "capsules on disk", and actual updates will
> take place at the next boot time.
>
> In this commit, we will support capsule on disk mechanism.
>
> Please note that U-Boot itself has no notion of "boot device" and
> all the capsule files to be executed will be detected only if they
> are located in a specific directory, \EFI\UpdateCapsule, on a device
> that is identified as a boot device by "BootXXXX" variables.
>
> Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
> ---

<snip />

> +static efi_status_t efi_capsule_scan_dir(u16 ***files, unsigned int *num)
> +{
> +	struct efi_file_handle *dirh;
> +	struct efi_file_info *dirent;
> +	efi_uintn_t dirent_size, tmp_size;
> +	unsigned int count;
> +	u16 **tmp_files;
> +	efi_status_t ret;
> +
> +	ret = find_boot_device();
> +	if (ret == EFI_NOT_FOUND) {
> +		EFI_PRINT("EFI Capsule: bootdev is not set\n");
> +		*num = 0;
> +		return EFI_SUCCESS;
> +	} else if (ret != EFI_SUCCESS) {
> +		return EFI_DEVICE_ERROR;
> +	}
> +
> +	/* count capsule files */
> +	ret = EFI_CALL((*bootdev_root->open)(bootdev_root, &dirh,
> +					     EFI_CAPSULE_DIR,
> +					     EFI_FILE_MODE_READ, 0));
> +	if (ret != EFI_SUCCESS) {
> +		*num = 0;
> +		return EFI_SUCCESS;
> +	}
> +
> +	dirent_size = 256;
> +	dirent = malloc(dirent_size);
> +	if (!dirent)
> +		return EFI_OUT_OF_RESOURCES;
> +
> +	count = 0;
> +	while (1) {
> +		tmp_size = dirent_size;
> +		ret = EFI_CALL((*dirh->read)(dirh, &tmp_size, dirent));
> +		if (ret == EFI_BUFFER_TOO_SMALL) {
> +			dirent = realloc(dirent, tmp_size);
> +			if (!dirent) {

If realloc() fails, you should free the *old* pointer.

Best regards

Heinrich

> +				ret = EFI_OUT_OF_RESOURCES;
> +				goto err;
> +			}

  parent reply	other threads:[~2021-03-17 21:02 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-30  9:12 [PATCH v10 00/11] efi_loader: add capsule update support AKASHI Takahiro
2020-11-30  9:12 ` [PATCH v10 01/11] efi_loader: define UpdateCapsule api AKASHI Takahiro
2020-11-30  9:12 ` [PATCH v10 02/11] efi_loader: capsule: add capsule_on_disk support AKASHI Takahiro
2021-02-16 10:24   ` Heinrich Schuchardt
2021-02-16 11:38     ` AKASHI Takahiro
2021-03-17 21:02   ` Heinrich Schuchardt [this message]
2020-11-30  9:12 ` [PATCH v10 03/11] efi_loader: capsule: add memory range capsule definitions AKASHI Takahiro
2020-11-30  9:12 ` [PATCH v10 04/11] efi_loader: capsule: support firmware update AKASHI Takahiro
2020-11-30  9:12 ` [PATCH v10 05/11] efi_loader: add firmware management protocol for FIT image AKASHI Takahiro
2020-11-30  9:12 ` [PATCH v10 06/11] efi_loader: add firmware management protocol for raw image AKASHI Takahiro
2020-11-30  9:12 ` [PATCH v10 07/11] cmd: add "efidebug capsule" command AKASHI Takahiro
2020-11-30  9:12 ` [PATCH v10 08/11] tools: add mkeficapsule command for UEFI capsule update AKASHI Takahiro
2020-11-30  9:12 ` [PATCH v10 09/11] test/py: efi_capsule: test for FIT image capsule AKASHI Takahiro
2020-11-30  9:12 ` [PATCH v10 10/11] test/py: efi_capsule: test for raw " AKASHI Takahiro
2020-11-30  9:12 ` [PATCH v10 11/11] sandbox: enable capsule update for testing AKASHI Takahiro
2020-12-02 14:37   ` Heinrich Schuchardt
2020-12-02 15:55     ` Tom Rini

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=ff23d85d-7bd5-8c4d-5e33-c3e805318d22@gmx.de \
    --to=xypron.glpk@gmx.de \
    --cc=u-boot@lists.denx.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.