Skip to contentSkip to conversation

arm: kernel: add NULL pointer check in early_mem()

PATCH In review Austin Kim 1 participant 2 messages Apr 3 – Apr 20 Arm (32-bit)

lore
Share & tools
lore

Austin Kim

author
#0 lore raw

PATCH 1/1 arm: kernel: add NULL pointer check in early_mem()

The 'early_mem' function handles memory-related boot parameters. If the parameter 'p' is passed as NULL, it could lead to an uninitialized or invalid memory access during parsing.

This patch adds a NULL pointer check at the beginning of the function to return early if no argument is provided, ensuring system stability during the early boot process.

---
 arch/arm/kernel/setup.c | 2 ++
 1 file changed, 2 insertions(+)
arch/arm/kernel/setup.c +2 -0
index 0bfd66c7a..b718a7df3 100644
@@ -830,6 +830,8 @@ static int __init early_mem(char *p)
 	u64 start;
 	char *endp;
 
+	if (!p)
+		return 1;
 	/*
 	 * If the user specifies memory size, we
 	 * blow away any automatically generated
Signature · 1 line
2.34.1
author
#1 lore raw

2026년 4월 3일 (금) 오후 3:08, Austin Kim <[email protected]>님이 작성:

Quoted 19 lines

The 'early_mem' function handles memory-related boot parameters. If the parameter 'p' is passed as NULL, it could lead to an uninitialized or invalid memory access during parsing.

This patch adds a NULL pointer check at the beginning of the function to return early if no argument is provided, ensuring system stability during the early boot process.

---
 arch/arm/kernel/setup.c | 2 ++
 1 file changed, 2 insertions(+)
arch/arm/kernel/setup.c +0 -0
index 0bfd66c7a..b718a7df3 100644

arch/arm/kernel/setup.c static int __init early_mem(char *p) · line 834

Quoted 5 lines
arch/arm/kernel/setup.c +2 -0
@@ -830,6 +830,8 @@ static int __init early_mem(char *p)
        u64 start;
        char *endp;
 
+       if (!p)
+               return 1;

Hello, Maintainers

If you are available, would you please leave any comments over this patch?

BR,
Austin Kim

Quoted 6 lines
arch/arm/kernel/setup.c +0 -1
        /*
         * If the user specifies memory size, we
         * blow away any automatically generated
--

2.34.1