[PATCH 1/3] efi_loader: shorten efi_bootmgr_release_uridp_resource()

We use this function to clean up leftover resources when booting an EFI HTTP boot image, but the name is unnecessary long.
Shorten it to efi_bootmgr_release_uridp()
Signed-off-by: Ilias Apalodimas ilias.apalodimas@linaro.org --- lib/efi_loader/efi_bootmgr.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/lib/efi_loader/efi_bootmgr.c b/lib/efi_loader/efi_bootmgr.c index 589d3996b680..181fc8775b96 100644 --- a/lib/efi_loader/efi_bootmgr.c +++ b/lib/efi_loader/efi_bootmgr.c @@ -380,12 +380,12 @@ err: }
/** - * efi_bootmgr_release_uridp_resource() - cleanup uri device path resource + * efi_bootmgr_release_uridp() - cleanup uri device path resource * * @ctx: event context * Return: status code */ -efi_status_t efi_bootmgr_release_uridp_resource(struct uridp_context *ctx) +efi_status_t efi_bootmgr_release_uridp(struct uridp_context *ctx) { efi_status_t ret = EFI_SUCCESS;
@@ -432,7 +432,7 @@ static void EFIAPI efi_bootmgr_image_return_notify(struct efi_event *event, efi_status_t ret;
EFI_ENTRY("%p, %p", event, context); - ret = efi_bootmgr_release_uridp_resource(context); + ret = efi_bootmgr_release_uridp(context); EFI_EXIT(ret); }
@@ -544,7 +544,7 @@ static efi_status_t try_load_from_uri_path(struct efi_device_path_uri *uridp, return ret;
err: - efi_bootmgr_release_uridp_resource(ctx); + efi_bootmgr_release_uridp(ctx);
return ret; }

We use this event when returning from an EFI HTTP booted image. The name is a bit confusing since it suggests we always run it, rename it to make it clearer
Signed-off-by: Ilias Apalodimas ilias.apalodimas@linaro.org --- lib/efi_loader/efi_bootmgr.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/lib/efi_loader/efi_bootmgr.c b/lib/efi_loader/efi_bootmgr.c index 181fc8775b96..03cdee15017d 100644 --- a/lib/efi_loader/efi_bootmgr.c +++ b/lib/efi_loader/efi_bootmgr.c @@ -421,13 +421,13 @@ efi_status_t efi_bootmgr_release_uridp(struct uridp_context *ctx) }
/** - * efi_bootmgr_image_return_notify() - return to efibootmgr callback + * efi_bootmgr_http_return() - return to efibootmgr callback * * @event: the event for which this notification function is registered * @context: event context */ -static void EFIAPI efi_bootmgr_image_return_notify(struct efi_event *event, - void *context) +static void EFIAPI efi_bootmgr_http_return(struct efi_event *event, + void *context) { efi_status_t ret;
@@ -533,7 +533,7 @@ static efi_status_t try_load_from_uri_path(struct efi_device_path_uri *uridp,
/* create event for cleanup when the image returns or error occurs */ ret = efi_create_event(EVT_NOTIFY_SIGNAL, TPL_CALLBACK, - efi_bootmgr_image_return_notify, ctx, + efi_bootmgr_http_return, ctx, &efi_guid_event_group_return_to_efibootmgr, &event); if (ret != EFI_SUCCESS) {

On Mon, 12 Aug 2024 at 14:56, Ilias Apalodimas ilias.apalodimas@linaro.org wrote:
We use this event when returning from an EFI HTTP booted image. The name is a bit confusing since it suggests we always run it, rename it to make it clearer
Signed-off-by: Ilias Apalodimas ilias.apalodimas@linaro.org
lib/efi_loader/efi_bootmgr.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
Reviewed-by: Simon Glass sjg@chromium.org

There's currently a chance for this function to overwrite an error if one occurred and the subsequent call to efi_uninstall_multiple_protocol_interfaces() succedded. Although this is an EFI event and we can't do much let's at least set and return the correct error
Signed-off-by: Ilias Apalodimas ilias.apalodimas@linaro.org --- lib/efi_loader/efi_bootmgr.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/lib/efi_loader/efi_bootmgr.c b/lib/efi_loader/efi_bootmgr.c index 03cdee15017d..a3aa2b8d1b92 100644 --- a/lib/efi_loader/efi_bootmgr.c +++ b/lib/efi_loader/efi_bootmgr.c @@ -388,6 +388,7 @@ err: efi_status_t efi_bootmgr_release_uridp(struct uridp_context *ctx) { efi_status_t ret = EFI_SUCCESS; + efi_status_t ret2 = EFI_SUCCESS;
if (!ctx) return ret; @@ -407,17 +408,18 @@ efi_status_t efi_bootmgr_release_uridp(struct uridp_context *ctx)
/* cleanup for PE-COFF image */ if (ctx->mem_handle) { - ret = efi_uninstall_multiple_protocol_interfaces( - ctx->mem_handle, &efi_guid_device_path, ctx->loaded_dp, - NULL); - if (ret != EFI_SUCCESS) + ret2 = efi_uninstall_multiple_protocol_interfaces(ctx->mem_handle, + &efi_guid_device_path, + ctx->loaded_dp, + NULL); + if (ret2 != EFI_SUCCESS) log_err("Uninstall device_path protocol failed\n"); }
efi_free_pool(ctx->loaded_dp); free(ctx);
- return ret; + return ret == EFI_SUCCESS ? ret2 : ret; }
/**

On Mon, 12 Aug 2024 at 14:57, Ilias Apalodimas ilias.apalodimas@linaro.org wrote:
There's currently a chance for this function to overwrite an error if one occurred and the subsequent call to efi_uninstall_multiple_protocol_interfaces() succedded. Although this is an EFI event and we can't do much let's at least set and return the correct error
Signed-off-by: Ilias Apalodimas ilias.apalodimas@linaro.org
lib/efi_loader/efi_bootmgr.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/lib/efi_loader/efi_bootmgr.c b/lib/efi_loader/efi_bootmgr.c index 03cdee15017d..a3aa2b8d1b92 100644 --- a/lib/efi_loader/efi_bootmgr.c +++ b/lib/efi_loader/efi_bootmgr.c @@ -388,6 +388,7 @@ err: efi_status_t efi_bootmgr_release_uridp(struct uridp_context *ctx) { efi_status_t ret = EFI_SUCCESS;
efi_status_t ret2 = EFI_SUCCESS; if (!ctx) return ret;
@@ -407,17 +408,18 @@ efi_status_t efi_bootmgr_release_uridp(struct uridp_context *ctx)
/* cleanup for PE-COFF image */ if (ctx->mem_handle) {
ret = efi_uninstall_multiple_protocol_interfaces(
ctx->mem_handle, &efi_guid_device_path, ctx->loaded_dp,
NULL);
if (ret != EFI_SUCCESS)
ret2 = efi_uninstall_multiple_protocol_interfaces(ctx->mem_handle,
&efi_guid_device_path,
ctx->loaded_dp,
NULL);
if (ret2 != EFI_SUCCESS) log_err("Uninstall device_path protocol failed\n"); } efi_free_pool(ctx->loaded_dp); free(ctx);
return ret;
return ret == EFI_SUCCESS ? ret2 : ret;
Reviewed-by: Simon Glass sjg@chromium.org
I would love the EFI code to use the same if (true/false) that the rest of U-Boot uses for errors, e.g.
return ret ? ret : ret2;
Regards, Simon

On Mon, 12 Aug 2024 at 14:56, Ilias Apalodimas ilias.apalodimas@linaro.org wrote:
We use this function to clean up leftover resources when booting an EFI HTTP boot image, but the name is unnecessary long.
Shorten it to efi_bootmgr_release_uridp()
Signed-off-by: Ilias Apalodimas ilias.apalodimas@linaro.org
lib/efi_loader/efi_bootmgr.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
horray!
Reviewed-by: Simon Glass sjg@chromium.org
participants (2)
-
Ilias Apalodimas
-
Simon Glass