Skip to content

Commit

Permalink
efi_loader: use efi_install_multiple_protocol_interfaces()
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
apalos authored and xypron committed Jul 20, 2023
1 parent 6287021 commit 4a3baf9
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/efi_loader/efi_tcg2.c
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 4a3baf9

Please sign in to comment.