U-Boot Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] efi_selftest: fix guid comparison
@ 2026-06-11  9:29 Vincent Stehlé
  2026-06-11 12:27 ` Ilias Apalodimas
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Vincent Stehlé @ 2026-06-11  9:29 UTC (permalink / raw)
  To: u-boot
  Cc: Vincent Stehlé, Heinrich Schuchardt, Ilias Apalodimas,
	Tom Rini, Alexander Graf

The `loaded image' efi selftest is comparing protocol GUIDs with the wrong
polarity.
This can be verified on the sandbox, where two protocols GUIDs are
retrieved by the test from the image handle in the following order:

1. Loaded Image Device Path Protocol GUID
2. Loaded Image Protocol GUID

The test matches on the first GUID, while it is in fact looking for the
second one; fix the comparison polarity.

While at it, use guidcmp() instead of memcmp() to spare the size parameter,
and use the Loaded Image Protocol GUID definition from efi_api.h instead or
redefining it locally.

Fixes: efe79a7c0de0 ("efi_selftest: test for loaded image protocol")
Signed-off-by: Vincent Stehlé <vincent.stehle@arm.com>
Cc: Heinrich Schuchardt <xypron.glpk@gmx.de>
Cc: Ilias Apalodimas <ilias.apalodimas@linaro.org>
Cc: Tom Rini <trini@konsulko.com>
Cc: Alexander Graf <agraf@suse.de>
---
 lib/efi_selftest/efi_selftest_loaded_image.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/lib/efi_selftest/efi_selftest_loaded_image.c b/lib/efi_selftest/efi_selftest_loaded_image.c
index 5889ab12617..48890a66db7 100644
--- a/lib/efi_selftest/efi_selftest_loaded_image.c
+++ b/lib/efi_selftest/efi_selftest_loaded_image.c
@@ -9,9 +9,7 @@
 
 #include <efi_selftest.h>
 
-static efi_guid_t loaded_image_protocol_guid =
-	EFI_GUID(0x5b1b31a1, 0x9562, 0x11d2,
-		 0x8e, 0x3f, 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b);
+static efi_guid_t loaded_image_protocol_guid = EFI_LOADED_IMAGE_PROTOCOL_GUID;
 static struct efi_boot_services *boottime;
 efi_handle_t image_handle;
 
@@ -60,8 +58,7 @@ static int execute(void)
 	efi_st_printf("%u protocols installed on image handle\n",
 		      (unsigned int)protocol_buffer_count);
 	for (i = 0; i < protocol_buffer_count; ++i) {
-		if (memcmp(protocol_buffer[i], &loaded_image_protocol_guid,
-			   sizeof(efi_guid_t)))
+		if (!guidcmp(protocol_buffer[i], &loaded_image_protocol_guid))
 			found = true;
 	}
 	if (!found) {
-- 
2.53.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-06-15 10:56 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-11  9:29 [PATCH] efi_selftest: fix guid comparison Vincent Stehlé
2026-06-11 12:27 ` Ilias Apalodimas
2026-06-13  8:22 ` Heinrich Schuchardt
2026-06-15  9:57   ` Vincent Stehlé
2026-06-15 10:56 ` [PATCH v2] " Vincent Stehlé

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox