[efi] Unload vetoed drivers by image handle rather than driver handle

In most cases, the driver handle will be the image handle itself.
However, this is not required by the UEFI specification, and some
images will install multiple driver binding handles.

Use the image handle (extracted from the driver binding protocol
instance) when attempting to unload the driver's image.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
vbox
Michael Brown 2023-06-23 16:08:25 +01:00
parent c832580f19
commit f0b1025503
1 changed files with 6 additions and 3 deletions

View File

@ -78,14 +78,17 @@ struct efi_veto {
static int efi_veto_unload ( struct efi_veto *veto ) {
EFI_BOOT_SERVICES *bs = efi_systab->BootServices;
EFI_HANDLE driver = veto->driver;
EFI_HANDLE image = veto->image;
EFI_STATUS efirc;
int rc;
/* Unload the driver */
if ( ( efirc = bs->UnloadImage ( driver ) ) != 0 ) {
if ( ( efirc = bs->UnloadImage ( image ) ) != 0 ) {
rc = -EEFI ( efirc );
DBGC ( driver, "EFIVETO %s could not unload: %s\n",
efi_handle_name ( driver ), strerror ( rc ) );
DBGC ( driver, "EFIVETO %s could not unload",
efi_handle_name ( driver ) );
DBGC ( driver, " %s: %s\n", efi_handle_name ( image ),
strerror ( rc ) );
return rc;
}