From: AKASHI Takahiro <takahiro.akashi@linaro.org>
To: Ilias Apalodimas <ilias.apalodimas@linaro.org>
Cc: xypron.glpk@gmx.de, u-boot@lists.denx.de
Subject: Re: [RFC PATCH 2/2] cmd: replace efi_create_handle/add_protocol with InstallMultipleProtocol
Date: Thu, 6 Oct 2022 10:53:46 +0900 [thread overview]
Message-ID: <20221006015346.GC38245@laputa> (raw)
In-Reply-To: <20221005152603.3085754-3-ilias.apalodimas@linaro.org>
On Wed, Oct 05, 2022 at 06:26:02PM +0300, Ilias Apalodimas wrote:
> In general handles should only be deleted if the last remaining protocol
> is removed. Instead of explicitly calling
> efi_create_handle -> efi_add_protocol -> efi_delete_handle which blindly
> removes all protocols from a handle before removing it, use
> InstallMultiple/UninstallMultiple which adheres to the EFI spec and only
> deletes a handle if there are no additional protocols present
>
> Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
> ---
> cmd/bootefi.c | 13 ++++++-------
> 1 file changed, 6 insertions(+), 7 deletions(-)
>
> diff --git a/cmd/bootefi.c b/cmd/bootefi.c
> index 3041873afbbc..4ab68868cc7e 100644
> --- a/cmd/bootefi.c
> +++ b/cmd/bootefi.c
> @@ -509,12 +509,9 @@ efi_status_t efi_run_image(void *source_buffer, efi_uintn_t source_size)
> * Make sure that device for device_path exist
> * in load_image(). Otherwise, shell and grub will fail.
> */
> - ret = efi_create_handle(&mem_handle);
> - if (ret != EFI_SUCCESS)
> - goto out;
> -
> - ret = efi_add_protocol(mem_handle, &efi_guid_device_path,
> - file_path);
> + ret = efi_install_multiple_protocol_interfaces(&mem_handle,
> + &efi_guid_device_path,
> + file_path, NULL);
nitpick: NULL -> NULL, NULL
UEFI spec seems to require "A variable argument list containing pairs of
protocol GUIDs and protocol interfaces" even if a protocol interface won't be
used with GUID as NULL.
-Takahiro Akashi
> if (ret != EFI_SUCCESS)
> goto out;
> msg_path = file_path;
> @@ -542,7 +539,9 @@ efi_status_t efi_run_image(void *source_buffer, efi_uintn_t source_size)
> ret = do_bootefi_exec(handle, load_options);
>
> out:
> - efi_delete_handle(mem_handle);
> + efi_uninstall_multiple_protocol_interfaces(mem_handle,
> + &efi_guid_device_path,
> + file_path, NULL);
> efi_free_pool(file_path);
> return ret;
> }
> --
> 2.34.1
>
next prev parent reply other threads:[~2022-10-06 1:53 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-05 15:26 [RFC PATCH 0/2] Clean up protocol installation API Ilias Apalodimas
2022-10-05 15:26 ` [RFC PATCH 1/2] efi_loader: define internal implementations of install/uninstallmultiple Ilias Apalodimas
2022-10-06 1:49 ` AKASHI Takahiro
2022-10-06 3:02 ` Heinrich Schuchardt
2022-10-06 7:37 ` Ilias Apalodimas
2022-10-06 10:41 ` Ilias Apalodimas
2022-10-05 15:26 ` [RFC PATCH 2/2] cmd: replace efi_create_handle/add_protocol with InstallMultipleProtocol Ilias Apalodimas
2022-10-06 1:53 ` AKASHI Takahiro [this message]
2022-10-06 2:26 ` Heinrich Schuchardt
2022-10-06 7:38 ` Ilias Apalodimas
2022-10-06 9:43 ` Heinrich Schuchardt
2022-10-06 1:34 ` [RFC PATCH 0/2] Clean up protocol installation API AKASHI Takahiro
2022-10-06 6:55 ` Ilias Apalodimas
2022-10-06 9:54 ` Heinrich Schuchardt
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=20221006015346.GC38245@laputa \
--to=takahiro.akashi@linaro.org \
--cc=ilias.apalodimas@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