[PATCH] insert-sys-cert: fix use of uninitialized pointer with an empty System.map

From: lzhan011

Date: Mon Oct 05 2026 - 06:43:34 EST


From: lzhan011 <zhangleizhen645@xxxxxxxxx>

get_symbol_from_map() only assigns n inside the loop that reads the
System.map file. If the file is empty, the loop body never runs and n is
then tested while uninitialized, as reported by MemorySanitizer.

Initialize n to NULL.

Fixes: c4c361059585 ("KEYS: Reserve an extra certificate symbol for inserting without recompiling")
Assisted-by: Claude:claude-opus-5-5 MSan
Signed-off-by: lzhan011 <zhangleizhen645@xxxxxxxxx>
---
scripts/insert-sys-cert.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/scripts/insert-sys-cert.c b/scripts/insert-sys-cert.c
index 8902836c2..e0bf0afc1 100644
--- a/scripts/insert-sys-cert.c
+++ b/scripts/insert-sys-cert.c
@@ -94,7 +94,7 @@ static void get_symbol_from_map(Elf_Ehdr *hdr, FILE *f, char *name,
struct sym *s)
{
char l[LINE_SIZE];
- char *w, *p, *n;
+ char *w, *p, *n = NULL;

s->size = 0;
s->address = 0;
--
2.34.1