[PATCH 1/2 v2] efi_loader: use efi_install_multiple_protocol_interfaces()

The TCG2 protocol currently adds and removes protocols with efi_(add/remove)_protocol().
Removing protocols with efi_remove_protocol() might prove problematic since it doesn't call DisconnectController() when uninstalling the protocol and does not comply with the UEFI specification.
It's also beneficial for readability to have protocol installations and removals in pairs -- IOW when efi_install_multiple_protocol_interfaces() is called, efi_uninstall_multiple_protocol_interfaces() should be used to remove it. So let's swap the efi_add_protocol() as well.
Signed-off-by: Ilias Apalodimas ilias.apalodimas@linaro.org --- Changes since v1: - Add a proper justification on the commit message
lib/efi_loader/efi_tcg2.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/lib/efi_loader/efi_tcg2.c b/lib/efi_loader/efi_tcg2.c index a83ae7a46cf3..49f8a5e77cbf 100644 --- a/lib/efi_loader/efi_tcg2.c +++ b/lib/efi_loader/efi_tcg2.c @@ -1680,8 +1680,8 @@ void tcg2_uninit(void) if (!is_tcg2_protocol_installed()) return;
- ret = efi_remove_protocol(efi_root, &efi_guid_tcg2_protocol, - (void *)&efi_tcg2_protocol); + ret = efi_uninstall_multiple_protocol_interfaces(efi_root, &efi_guid_tcg2_protocol, + &efi_tcg2_protocol, NULL); if (ret != EFI_SUCCESS) log_err("Failed to remove EFI TCG2 protocol\n"); } @@ -2507,8 +2507,8 @@ efi_status_t efi_tcg2_register(void) goto fail; }
- ret = efi_add_protocol(efi_root, &efi_guid_tcg2_protocol, - (void *)&efi_tcg2_protocol); + ret = efi_install_multiple_protocol_interfaces(&efi_root, &efi_guid_tcg2_protocol, + &efi_tcg2_protocol, NULL); if (ret != EFI_SUCCESS) { tcg2_uninit(); goto fail; -- 2.40.1

A previous patch is removing the last consumer of efi_remove_protocol(). Switch that to static and treat it as an internal API in order to force users install and remove protocols with the appropriate EFI functions.
It's worth noting that we still have files using efi_add_protocol(). We should convert all these to efi_install_multiple_protocol_interfaces() and treat efi_add_protocol() in a similar manner
Reviewed-by: Heinrich Schuchardt xypron.glpk@gmx.de Signed-off-by: Ilias Apalodimas ilias.apalodimas@linaro.org --- Changes since v2: - Add r-b tags include/efi_loader.h | 4 ---- lib/efi_loader/efi_boottime.c | 6 +++--- 2 files changed, 3 insertions(+), 7 deletions(-)
diff --git a/include/efi_loader.h b/include/efi_loader.h index 11e08a804f7f..90a2f72d6929 100644 --- a/include/efi_loader.h +++ b/include/efi_loader.h @@ -651,10 +651,6 @@ efi_status_t efi_protocol_open(struct efi_handler *handler, void **protocol_interface, void *agent_handle, void *controller_handle, uint32_t attributes);
-/* Delete protocol from a handle */ -efi_status_t efi_remove_protocol(const efi_handle_t handle, - const efi_guid_t *protocol, - void *protocol_interface); /* Install multiple protocol interfaces */ efi_status_t EFIAPI efi_install_multiple_protocol_interfaces(efi_handle_t *handle, ...); diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c index d5065f296aee..5006c0e1e4af 100644 --- a/lib/efi_loader/efi_boottime.c +++ b/lib/efi_loader/efi_boottime.c @@ -569,9 +569,9 @@ efi_status_t efi_search_protocol(const efi_handle_t handle, * * Return: status code */ -efi_status_t efi_remove_protocol(const efi_handle_t handle, - const efi_guid_t *protocol, - void *protocol_interface) +static efi_status_t efi_remove_protocol(const efi_handle_t handle, + const efi_guid_t *protocol, + void *protocol_interface) { struct efi_handler *handler; efi_status_t ret; -- 2.40.1
participants (1)
-
Ilias Apalodimas