From 5a5e2a1dae525aecf97dffde2236b74710735c8d Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Sun, 23 Mar 2025 19:38:14 +0000 Subject: [efi] Use efi_open_unsafe() for all explicitly unsafe protocol opens Signed-off-by: Michael Brown --- src/interface/efi/efi_init.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'src/interface/efi/efi_init.c') diff --git a/src/interface/efi/efi_init.c b/src/interface/efi/efi_init.c index d3c5042d7..a45ee66a4 100644 --- a/src/interface/efi/efi_init.c +++ b/src/interface/efi/efi_init.c @@ -241,14 +241,17 @@ EFI_STATUS efi_init ( EFI_HANDLE image_handle, } } - /* Get loaded image protocol */ - if ( ( efirc = bs->OpenProtocol ( image_handle, - &efi_loaded_image_protocol_guid, - &loaded_image, image_handle, NULL, - EFI_OPEN_PROTOCOL_GET_PROTOCOL ) ) != 0 ) { - rc = -EEFI ( efirc ); + /* Get loaded image protocol + * + * We assume that our loaded image protocol will not be + * uninstalled while our image code is still running. + */ + if ( ( rc = efi_open_unsafe ( image_handle, + &efi_loaded_image_protocol_guid, + &loaded_image ) ) != 0 ) { DBGC ( systab, "EFI could not get loaded image protocol: %s", strerror ( rc ) ); + efirc = EFIRC ( rc ); goto err_no_loaded_image; } efi_loaded_image = loaded_image; -- cgit v1.2.3-55-g7522