]> www.infradead.org Git - users/willy/pagecache.git/commitdiff
tracing: tprobe-events: Fix a memory leak when tprobe with $retval
authorMasami Hiramatsu (Google) <mhiramat@kernel.org>
Wed, 26 Feb 2025 06:18:46 +0000 (15:18 +0900)
committerMasami Hiramatsu (Google) <mhiramat@kernel.org>
Thu, 27 Feb 2025 00:10:21 +0000 (09:10 +0900)
Fix a memory leak when a tprobe is defined with $retval. This
combination is not allowed, but the parse_symbol_and_return() does
not free the *symbol which should not be used if it returns the error.
Thus, it leaks the *symbol memory in that error path.

Link: https://lore.kernel.org/all/174055072650.4079315.3063014346697447838.stgit@mhiramat.tok.corp.google.com/
Fixes: ce51e6153f77 ("tracing: fprobe-event: Fix to check tracepoint event and return")
Signed-off-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
Reviewed-by: Steven Rostedt (Google) <rostedt@goodmis.org>
Cc: stable@vger.kernel.org
kernel/trace/trace_fprobe.c

index b8f3c4ba309b636d9be7ace959e8a0554e5a06e5..8826f44f69a4401a0501f467682629b8b83248dd 100644 (file)
@@ -1056,6 +1056,8 @@ static int parse_symbol_and_return(int argc, const char *argv[],
                        if (is_tracepoint) {
                                trace_probe_log_set_index(i);
                                trace_probe_log_err(tmp - argv[i], RETVAL_ON_PROBE);
+                               kfree(*symbol);
+                               *symbol = NULL;
                                return -EINVAL;
                        }
                        *is_return = true;