[PATCH v3 04/11] efi_loader: fix void* check in open_file_system()

Heinrich Schuchardt heinrich.schuchardt at canonical.com
Sun Jun 28 10:28:02 CEST 2026


The UEFI specification requires FreePool() to return EFI_INVALID_PARAMETER
when the passed buffer is invalid. But it does not well define what
checks are required. Therefore we try to avoid passing NULL to
FreePool() in open_file_system() used by dtbdump.c and smbiosdump.c.
But we check the wrong variable.

Check the pointer to the handle buffer, not the handle.

Reviewed-by: Ilias Apalodimas <ilias.apalodimas at linaro.org>
Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt at canonical.com>
---
v3:
	rephrase the subject line and the commit message
v2:
	new patch
---
 lib/efi_loader/dtbdump.c    | 2 +-
 lib/efi_loader/smbiosdump.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/efi_loader/dtbdump.c b/lib/efi_loader/dtbdump.c
index 1e72404ecc1..865edc33a97 100644
--- a/lib/efi_loader/dtbdump.c
+++ b/lib/efi_loader/dtbdump.c
@@ -350,7 +350,7 @@ open_file_system(struct efi_simple_file_system_protocol **file_system)
 					EFI_OPEN_PROTOCOL_GET_PROTOCOL);
 	if (ret != EFI_SUCCESS)
 		error(u"Failed to open simple file system protocol\r\n");
-	if (handle)
+	if (handle_buffer)
 		bs->free_pool(handle_buffer);
 
 	return ret;
diff --git a/lib/efi_loader/smbiosdump.c b/lib/efi_loader/smbiosdump.c
index 974728a43af..494c3d18945 100644
--- a/lib/efi_loader/smbiosdump.c
+++ b/lib/efi_loader/smbiosdump.c
@@ -248,7 +248,7 @@ open_file_system(struct efi_simple_file_system_protocol **file_system)
 					EFI_OPEN_PROTOCOL_GET_PROTOCOL);
 	if (ret != EFI_SUCCESS)
 		error(u"Failed to open simple file system protocol\r\n");
-	if (handle)
+	if (handle_buffer)
 		bs->free_pool(handle_buffer);
 
 	return ret;
-- 
2.53.0



More information about the U-Boot mailing list