efi_loader: remove efi_delete_handle on loadfile2

Loadfile2 code is installing two protocols on it's own handle
and uses efi_delete_handle() to clean it up on failure(s). However
commit 05c4c9e21a ("efi_loader: define internal implementations of
install/uninstallmultiple") prepares the ground for us to clean up
efi_delete_handle() used in favor of Install/UninstallMultipleProtocol.

While at it clean up the non needed void casts to (void *) on the
protolcol installation.

Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
Reviewed-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
This commit is contained in:
Ilias Apalodimas 2022-10-16 11:36:32 +03:00 committed by Heinrich Schuchardt
parent f4d52c4159
commit 70089c13a7
3 changed files with 21 additions and 8 deletions

View File

@ -394,8 +394,10 @@ static efi_status_t do_bootefi_exec(efi_handle_t handle, void *load_options)
out: out:
free(load_options); free(load_options);
if (IS_ENABLED(CONFIG_EFI_LOAD_FILE2_INITRD)) if (IS_ENABLED(CONFIG_EFI_LOAD_FILE2_INITRD)) {
efi_initrd_deregister(); if (efi_initrd_deregister() != EFI_SUCCESS)
log_err("Failed to remove loadfile2 for initrd\n");
}
/* Control is returned to U-Boot, disable EFI watchdog */ /* Control is returned to U-Boot, disable EFI watchdog */
efi_set_watchdog(0); efi_set_watchdog(0);

View File

@ -570,7 +570,7 @@ efi_status_t efi_net_register(void);
/* Called by bootefi to make the watchdog available */ /* Called by bootefi to make the watchdog available */
efi_status_t efi_watchdog_register(void); efi_status_t efi_watchdog_register(void);
efi_status_t efi_initrd_register(void); efi_status_t efi_initrd_register(void);
void efi_initrd_deregister(void); efi_status_t efi_initrd_deregister(void);
/* Called by bootefi to make SMBIOS tables available */ /* Called by bootefi to make SMBIOS tables available */
/** /**
* efi_acpi_register() - write out ACPI tables * efi_acpi_register() - write out ACPI tables

View File

@ -213,7 +213,7 @@ efi_status_t efi_initrd_register(void)
&efi_guid_device_path, &dp_lf2_handle, &efi_guid_device_path, &dp_lf2_handle,
/* LOAD_FILE2 */ /* LOAD_FILE2 */
&efi_guid_load_file2_protocol, &efi_guid_load_file2_protocol,
(void *)&efi_lf2_protocol, &efi_lf2_protocol,
NULL); NULL);
return ret; return ret;
@ -227,11 +227,22 @@ efi_status_t efi_initrd_register(void)
* *
* Return: status code * Return: status code
*/ */
void efi_initrd_deregister(void) efi_status_t efi_initrd_deregister(void)
{ {
if (!efi_initrd_handle) efi_status_t ret;
return;
efi_delete_handle(efi_initrd_handle); if (!efi_initrd_handle)
return EFI_SUCCESS;
ret = efi_uninstall_multiple_protocol_interfaces(efi_initrd_handle,
/* initramfs */
&efi_guid_device_path,
&dp_lf2_handle,
/* LOAD_FILE2 */
&efi_guid_load_file2_protocol,
&efi_lf2_protocol,
NULL);
efi_initrd_handle = NULL; efi_initrd_handle = NULL;
return ret;
} }