[PATCH 1/4] lib/dynamic_debug: add NULL check after kstrdup
From: Martin Weiss
Date: Mon Jun 29 2026 - 05:36:41 EST
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.
Signed-off-by: Martin Weiss <Martin.weiss2410@xxxxxxxxx>
---
lib/dynamic_debug.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c
index 18a71a9108d3..59a04057b509 100644
--- a/lib/dynamic_debug.c
+++ b/lib/dynamic_debug.c
@@ -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);
--
2.54.0