[PATCH v13 34/39] dyndbg: fix attempt to modify an RO string

From
Jim Cromie via B4 Relay <devnull+jim.cromie.gmail.com@kernel.org>
Date
2026-10-27 20:22:24
Also in
b4-sent, dri-devel, linux-arch, linux-doc, linux-kbuild, linux-kselftest, linux-pm, lkml
Reply to
Jim Cromie via B4 Relay, 2026-10-27
From: Jim Cromie <jim.cromie@gmail.com>

ddebug_dyndbg_param_cb() passes an RO flags string "+p" to
ddebug_exec_queries() when no explicit param value is given, but
callee may attempt to modify it.  Fix by adding a local mutable var,
init'd with that value, and passing it instead.

Fixes: b48420c1d301 ("dynamic_debug: make dynamic-debug work for module initialization")
Signed-off-by: Jim Cromie <jim.cromie@gmail.com>
---
 lib/dynamic_debug.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c
index 5c87e92bbcdb..efc7a741008e 100644
--- a/lib/dynamic_debug.c
+++ b/lib/dynamic_debug.c
@@ -1637,8 +1637,9 @@ static int ddebug_add_module(struct _ddebug_info *di)
 
 /* helper for ddebug_dyndbg_(boot|module)_param_cb */
 static int ddebug_dyndbg_param_cb(char *param, char *val,
-				const char *modname, int on_err)
+				  const char *modname, int on_err)
 {
+	char dflt_flags[] = "+p";
 	char *sep;
 
 	sep = strchr(param, '.');
@@ -1651,7 +1652,7 @@ static int ddebug_dyndbg_param_cb(char *param, char *val,
 	if (strcmp(param, "dyndbg"))
 		return on_err; /* determined by caller */
 
-	ddebug_exec_queries((val ? val : "+p"), modname);
+	ddebug_exec_queries((val ? val : dflt_flags), modname);
 
 	return 0; /* query failure shouldn't stop module load */
 }
-- 
2.56.0

Thread (48 messages) 48 messages, 2 authors, last reply 18d ago
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help