From 3768968b1ea7abd587df1fcc3f9a528203fccb13 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vincent=20Stehl=C3=A9?= Date: Mon, 16 Feb 2026 12:30:16 +0100 Subject: efi_loader: fix specific LoadImage() return code MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When the LoadImage() UEFI function is called with both its SourceBuffer and DevicePath input arguments equal to NULL, it must return EFI_NOT_FOUND [1]. However, it does return EFI_INVALID_PARAMETER instead; fix it. Link: https://uefi.org/specs/UEFI/2.11/07_Services_Boot_Services.html#efi-boot-services-loadimage [1] Reported-by: Sathisha Shivaramappa Signed-off-by: Vincent Stehlé Cc: Heinrich Schuchardt Cc: Ilias Apalodimas Cc: Tom Rini --- lib/efi_loader/efi_boottime.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c index b424d924896..de57823bd44 100644 --- a/lib/efi_loader/efi_boottime.c +++ b/lib/efi_loader/efi_boottime.c @@ -2096,8 +2096,12 @@ efi_status_t EFIAPI efi_load_image(bool boot_policy, EFI_ENTRY("%d, %p, %pD, %p, %zu, %p", boot_policy, parent_image, file_path, source_buffer, source_size, image_handle); - if (!image_handle || (!source_buffer && !file_path) || - !efi_search_obj(parent_image) || + if (!source_buffer && !file_path) { + ret = EFI_NOT_FOUND; + goto error; + } + + if (!image_handle || !efi_search_obj(parent_image) || /* The parent image handle must refer to a loaded image */ !parent_image->type) { ret = EFI_INVALID_PARAMETER; -- cgit v1.2.3 From 02b74a786354db961f3e057f671d60fad9a17515 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vincent=20Stehl=C3=A9?= Date: Mon, 16 Feb 2026 12:30:17 +0100 Subject: efi_selftest: test specific LoadImage() case MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add a test calling the LoadImage() UEFI function with both its SourceBuffer and DevicePath input arguments equal to NULL. This test can be run on the sandbox with the following command: ./u-boot -T -c "setenv efi_selftest load image from file; \ bootefi selftest" Signed-off-by: Vincent Stehlé Cc: Heinrich Schuchardt Cc: Ilias Apalodimas Cc: Tom Rini --- lib/efi_selftest/efi_selftest_loadimage.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'lib') diff --git a/lib/efi_selftest/efi_selftest_loadimage.c b/lib/efi_selftest/efi_selftest_loadimage.c index 967eaa58c69..0e8fc6216f0 100644 --- a/lib/efi_selftest/efi_selftest_loadimage.c +++ b/lib/efi_selftest/efi_selftest_loadimage.c @@ -562,6 +562,13 @@ static int execute(void) return EFI_ST_FAILURE; } + ret = boottime->load_image(false, handle_image, NULL, NULL, 0, + &handle); + if (ret != EFI_NOT_FOUND) { + efi_st_error("Unexpected load_image return value\n"); + return EFI_ST_FAILURE; + } + return EFI_ST_SUCCESS; } -- cgit v1.2.3 From 89f6b9020db0960e219fc56d0d32aba82e42332a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vincent=20Stehl=C3=A9?= Date: Thu, 19 Feb 2026 19:44:00 +0100 Subject: efi_selftest: cosmetic: fix spelling in comments MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fix a few UEFI function names, as well as a typo. Signed-off-by: Vincent Stehlé Cc: Heinrich Schuchardt Cc: Ilias Apalodimas Cc: Tom Rini Reviewed-by: Ilias Apalodimas Reviewed-by: Heinrich Schuchardt --- lib/efi_selftest/efi_selftest_manageprotocols.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'lib') diff --git a/lib/efi_selftest/efi_selftest_manageprotocols.c b/lib/efi_selftest/efi_selftest_manageprotocols.c index 097b2ae3545..31ea67748a5 100644 --- a/lib/efi_selftest/efi_selftest_manageprotocols.c +++ b/lib/efi_selftest/efi_selftest_manageprotocols.c @@ -6,7 +6,7 @@ * * This unit test checks the following protocol services: * InstallProtocolInterface, UninstallProtocolInterface, - * InstallMultipleProtocolsInterfaces, UninstallMultipleProtocolsInterfaces, + * InstallMultipleProtocolInterfaces, UninstallMultipleProtocolInterfaces, * HandleProtocol, ProtocolsPerHandle, * LocateHandle, LocateHandleBuffer. */ @@ -189,7 +189,7 @@ static int execute(void) } /* - * Test error handling in UninstallMultipleProtocols + * Test error handling in UninstallMultipleProtocolInterfaces * * These are the installed protocol interfaces on handle 2: * @@ -240,7 +240,7 @@ static int execute(void) efi_st_error("LocateHandleBuffer failed to locate new handle\n"); return EFI_ST_FAILURE; } - /* Clear the buffer, we are reusing it it the next step. */ + /* Clear the buffer, we are reusing it in the next step. */ boottime->set_mem(buffer, sizeof(efi_handle_t) * buffer_size, 0); /* @@ -289,7 +289,7 @@ static int execute(void) } /* - * Test UninstallMultipleProtocols + * Test UninstallMultipleProtocolInterfaces */ ret = boottime->uninstall_multiple_protocol_interfaces( handle2, -- cgit v1.2.3