diff options
| author | Ian Rogers <irogers@google.com> | 2025-03-19 08:07:41 +0300 |
|---|---|---|
| committer | Namhyung Kim <namhyung@kernel.org> | 2025-03-21 08:58:35 +0300 |
| commit | 7b172b92c1aa4ef97977bf44f0d317c052fa6397 (patch) | |
| tree | 3b93722cddd965785005a3bb02adfea70ae7990f | |
| parent | 874fa827df50a9e1d258c7539e51cd945cc4a34d (diff) | |
| download | linux-7b172b92c1aa4ef97977bf44f0d317c052fa6397.tar.xz | |
perf trace: Fix evlist memory leak
Leak sanitizer was reporting a memory leak in the "perf record and
replay" test. Add evlist__delete to trace__exit, also ensure
trace__exit is called after trace__record.
Signed-off-by: Ian Rogers <irogers@google.com>
Reviewed-by: Namhyung Kim <namhyung@kernel.org>
Acked-by: Arnaldo Carvalho de Melo <acme@kernel.org>
Link: https://lore.kernel.org/r/20250319050741.269828-15-irogers@google.com
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
| -rw-r--r-- | tools/perf/builtin-trace.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c index 1d4ad5d19b10..a102748bd0c9 100644 --- a/tools/perf/builtin-trace.c +++ b/tools/perf/builtin-trace.c @@ -5339,6 +5339,8 @@ static void trace__exit(struct trace *trace) zfree(&trace->syscalls.table); } zfree(&trace->perfconfig_events); + evlist__delete(trace->evlist); + trace->evlist = NULL; #ifdef HAVE_LIBBPF_SUPPORT btf__free(trace->btf); trace->btf = NULL; @@ -5719,8 +5721,10 @@ init_augmented_syscall_tp: } } - if ((argc >= 1) && (strcmp(argv[0], "record") == 0)) - return trace__record(&trace, argc-1, &argv[1]); + if ((argc >= 1) && (strcmp(argv[0], "record") == 0)) { + err = trace__record(&trace, argc-1, &argv[1]); + goto out; + } /* Using just --errno-summary will trigger --summary */ if (trace.errno_summary && !trace.summary && !trace.summary_only) |
