tracing: Stop modifying the input buffer in ftrace_set_clr_event()

ftrace_set_clr_event() modifies its input buffer during parsing.
Before returning to the caller these modifications are undone.
This is restoration is error prone and was forgotten before.
Upcoming changes will also make it more complicated.

Copy the input argument and modify that copy and drop the
restoration logic.

Also mark the input argument as const.

Link: https://patch.msgid.link/20260908-tracing-cli-event-filter-v2-3-05396a3fb663@linutronix.de
Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
This commit is contained in:
Thomas Weißschuh 2026-09-08 08:22:17 +02:00 committed by Steven Rostedt
parent 37a39701f6
commit 82c9b6a058
2 changed files with 9 additions and 12 deletions

View File

@ -883,7 +883,7 @@ extern int trace_add_event_call(struct trace_event_call *call);
extern int trace_remove_event_call(struct trace_event_call *call);
extern int trace_event_get_offsets(struct trace_event_call *call);
int ftrace_set_clr_event(struct trace_array *tr, char *buf, int set);
int ftrace_set_clr_event(struct trace_array *tr, const char *buf, int set);
int trace_set_clr_event(const char *system, const char *event, int set);
int trace_array_set_clr_event(struct trace_array *tr, const char *system,
const char *event, bool enable);

View File

@ -1443,14 +1443,19 @@ static int __ftrace_set_clr_event(struct trace_array *tr, const char *match,
return ret;
}
int ftrace_set_clr_event(struct trace_array *tr, char *buf, int set)
int ftrace_set_clr_event(struct trace_array *tr, const char *arg_buf, int set)
{
char *event = NULL, *sub = NULL, *match, *mod;
int ret;
char *buf;
if (!tr)
return -ENOENT;
char *dupped_buf __free(kfree) = kstrdup(arg_buf, GFP_KERNEL);
if (!dupped_buf)
return -ENOMEM;
buf = dupped_buf;
/* Modules events can be appended with :mod:<module> */
mod = strstr(buf, ":mod:");
if (mod) {
@ -1487,15 +1492,7 @@ int ftrace_set_clr_event(struct trace_array *tr, char *buf, int set)
match = NULL;
}
ret = __ftrace_set_clr_event(tr, match, sub, event, set, mod);
/* Put back the colon to allow this to be called again */
if (buf)
*(buf - 1) = ':';
if (mod)
*(mod - 5) = ':';
return ret;
return __ftrace_set_clr_event(tr, match, sub, event, set, mod);
}
/**