Skip to contentSkip to conversation

lib/dynamic_debug: add NULL check after kstrdup

PATCH In review Martin Weiss 2 participants 5 messages Jun 29

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/4 lib/dynamic_debug: add NULL check after kstrdup

kstrdup(saved_command_line, GFP_KERNEL) may return NULL under memory pressure. Add a check to avoid NULL pointer dereference during boot-time dynamic debug parameter parsing.

---
 lib/dynamic_debug.c | 2 ++
 1 file changed, 2 insertions(+)
lib/dynamic_debug.c +2 -0
index 18a71a9108d3..59a04057b509 100644
@@ -1479,6 +1479,8 @@ static int __init dynamic_debug_init(void)
 	 * slightly noisy if verbose, but harmless.
 	 */
 	cmdline = kstrdup(saved_command_line, GFP_KERNEL);
+	if (!cmdline)
+		return 0; /* prevents a boot-time NULL deref */
 	parse_args("dyndbg params", cmdline, NULL,
 		   0, 0, 0, NULL, &ddebug_dyndbg_boot_param_cb);
 	kfree(cmdline);
Signature · 1 line
2.54.0
#1 lore raw

PATCH 2/4 selftests: filesystems: fix spelling mistake in statmount test

---
 tools/testing/selftests/filesystems/statmount/statmount_test.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/filesystems/statmount/statmount_test.c +1 -1
index 8dc018d47a93..9d963e09e510 100644
@@ -515,7 +515,7 @@ static void test_statmount_mnt_opts(void)
 		return;
 	}
 
-	ksft_test_result_fail("didnt't find mount entry\n");
+	ksft_test_result_fail("didn't find mount entry\n");
 	free(sm);
 	free(line);
 }
Signature · 1 line
2.54.0
#2 lore raw

PATCH 3/4 selftests: powerpc: fix spelling mistake

In reply to Martin Weiss
---
 tools/testing/selftests/powerpc/tm/tm-tar.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/powerpc/tm/tm-tar.c +1 -1
index f2a9137f3c1e..ea420caa3961 100644
@@ -50,7 +50,7 @@ int test_tar(void)
 			"bne	2b;"
 			"tend.;"
 
-			/* Transaction sucess! TAR should be 3 */
+			/* Transaction success! TAR should be 3 */
 			"mfspr  7, %[tar];"
 			"ori	%[res], 7, 4;"  // res = 3|4 = 7
 			"b	4f;"
Signature · 1 line
2.54.0
#3 lore raw

PATCH 4/4 tools/build: fix spelling mistake in documentation

In reply to Martin Weiss
---
 tools/build/Documentation/Build.txt | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/build/Documentation/Build.txt +1 -1
index a22587475dbe..da037299dfd1 100644
@@ -102,7 +102,7 @@ Makefile.include
 ----------------
 
 The tools/build/Makefile.include makefile could be included
-via user makefiles to get usefull definitions.
+via user makefiles to get useful definitions.
 
 It defines following interface:
 
Signature · 1 line
2.54.0
maintainer
#4 lore raw
In reply to Martin Weiss
Quoted 4 lines · On Mon, 29 Jun 2026 16:30:51 +0700 Martin Weiss <[email protected]>…

kstrdup(saved_command_line, GFP_KERNEL) may return NULL under memory pressure. Add a check to avoid NULL pointer dereference during boot-time dynamic debug parameter parsing.

Thanks.

lib/dynamic_debug.c static int __init dynamic_debug_init(void) · line 1486

Quoted 11 lines
lib/dynamic_debug.c +2 -0
@@ -1479,6 +1479,8 @@ static int __init dynamic_debug_init(void)
 	 * slightly noisy if verbose, but harmless.
 	 */
 	cmdline = kstrdup(saved_command_line, GFP_KERNEL);
+	if (!cmdline)
+		return 0; /* prevents a boot-time NULL deref */
 	parse_args("dyndbg params", cmdline, NULL,
 		   0, 0, 0, NULL, &ddebug_dyndbg_boot_param_cb);
 	kfree(cmdline);

We conventionally assume that memory allocations at __init time cannot fail. Sashiko explains why ;)

	https://sashiko.dev/#/patchset/[email protected]