[PATCH v2 1/7] efi_loader: Fix free in ..._media_device_boot_option()

Simon Glass sjg at chromium.org
Mon Dec 2 01:12:37 CET 2024


Freeing a NULL pointer is an error in EFI, so check the pointer first,
before freeing it.

Signed-off-by: Simon Glass <sjg at chromium.org>
---

(no changes since v1)

 lib/efi_loader/efi_bootmgr.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/lib/efi_loader/efi_bootmgr.c b/lib/efi_loader/efi_bootmgr.c
index e3b8dfb6013..cb5ea0e4040 100644
--- a/lib/efi_loader/efi_bootmgr.c
+++ b/lib/efi_loader/efi_bootmgr.c
@@ -1186,7 +1186,8 @@ out:
 			free(opt[i].lo);
 	}
 	free(opt);
-	efi_free_pool(handles);
+	if (handles)
+		efi_free_pool(handles);
 
 	if (ret == EFI_NOT_FOUND)
 		return EFI_SUCCESS;
-- 
2.34.1



More information about the U-Boot mailing list