[PATCH master 01/39] efi: fix potential NULL dereference

Ahmad Fatoum a.fatoum at pengutronix.de
Mon Feb 16 00:44:01 PST 2026


Add NULL check for name buffer before writing to it.  When called with
name=NULL (for length query), the loop would dereference a NULL pointer.

Reported-by: clang-analyzer 19.1.7
Co-Authored-By: Claude Opus 4.6 <noreply at anthropic.com>
Signed-off-by: Ahmad Fatoum <a.fatoum at pengutronix.de>
---
 efi/efivar-filename.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/efi/efivar-filename.c b/efi/efivar-filename.c
index 984e40bc1c85..96a00ed001ff 100644
--- a/efi/efivar-filename.c
+++ b/efi/efivar-filename.c
@@ -79,6 +79,9 @@ int __efivarfs_parse_filename(const char *filename, efi_guid_t *vendor,
 	if (ret)
 		return ret;
 
+	if (!name)
+		return 0;
+
 	for (i = 0; i < *namelen - 1; i++)
 		name[i] = filename[i];
 
-- 
2.47.3




More information about the barebox mailing list