From c2916395a9bb2207fc588e6c89f8cf3b434edae3 Mon Sep 17 00:00:00 2001 From: Daniele Lacamera Date: Fri, 4 Sep 2026 21:08:36 +0200 Subject: [PATCH] x86_64_efi: early-return after remaining panic() sites under UNIT_TEST do_boot() already returned after its panic() calls, but GetVolume() and efi_main() did not: under UNIT_TEST panic() returns, so GetVolume() hit a NULL deref / uninitialized return and efi_main() ran wolfBoot_start(). Return NULL / EFI_LOAD_ERROR at each site (unreachable on target). --- hal/x86_64_efi.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/hal/x86_64_efi.c b/hal/x86_64_efi.c index e7f1fddf..4937ebd0 100644 --- a/hal/x86_64_efi.c +++ b/hal/x86_64_efi.c @@ -210,19 +210,25 @@ static EFI_FILE_HANDLE GetVolume(EFI_HANDLE image) status = uefi_call_wrapper(BS->HandleProtocol, 3, image, &lipGuid, (void **) &loaded_image); - if (status != EFI_SUCCESS) + if (status != EFI_SUCCESS) { panic(); + return NULL; /* Never reached on target (panic() does not return) */ + } status = uefi_call_wrapper(BS->HandleProtocol, 3, loaded_image->DeviceHandle, &fsGuid, (VOID*)&IOVolume); - if (status != EFI_SUCCESS) + if (status != EFI_SUCCESS) { panic(); + return NULL; /* Never reached on target (panic() does not return) */ + } status = uefi_call_wrapper(IOVolume->OpenVolume, 2, IOVolume, &Volume); - if (status != EFI_SUCCESS) + if (status != EFI_SUCCESS) { panic(); + return NULL; /* Never reached on target (panic() does not return) */ + } return Volume; } @@ -353,6 +359,8 @@ efi_main (EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable) if (kernel_addr == 0 && update_addr == 0) { wolfBoot_printf("No image to load\n"); panic(); + return EFI_LOAD_ERROR; /* Never reached on target (panic() does not + * return) */ } wolfBoot_start();