[PATCH v2025.09.y 30/58] efi: fix potential NULL dereference

Ahmad Fatoum a.fatoum at pengutronix.de
Fri Mar 13 06:25:14 PDT 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.

(cherry picked from commit c54a80c2e557dafb970d21df9fd4a025908bee16)

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>
Link: https://lore.barebox.org/20260216084758.3548990-2-a.fatoum@pengutronix.de
Signed-off-by: Sascha Hauer <s.hauer 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 51d0130fa774..7660d6cb0c57 100644
--- a/efi/efivar-filename.c
+++ b/efi/efivar-filename.c
@@ -78,6 +78,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