Skip to content

Commit 7b172b9

Browse files
captain5050namhyung
authored andcommitted
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 <[email protected]> Reviewed-by: Namhyung Kim <[email protected]> Acked-by: Arnaldo Carvalho de Melo <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Namhyung Kim <[email protected]>
1 parent 874fa82 commit 7b172b9

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

tools/perf/builtin-trace.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5339,6 +5339,8 @@ static void trace__exit(struct trace *trace)
53395339
zfree(&trace->syscalls.table);
53405340
}
53415341
zfree(&trace->perfconfig_events);
5342+
evlist__delete(trace->evlist);
5343+
trace->evlist = NULL;
53425344
#ifdef HAVE_LIBBPF_SUPPORT
53435345
btf__free(trace->btf);
53445346
trace->btf = NULL;
@@ -5719,8 +5721,10 @@ int cmd_trace(int argc, const char **argv)
57195721
}
57205722
}
57215723

5722-
if ((argc >= 1) && (strcmp(argv[0], "record") == 0))
5723-
return trace__record(&trace, argc-1, &argv[1]);
5724+
if ((argc >= 1) && (strcmp(argv[0], "record") == 0)) {
5725+
err = trace__record(&trace, argc-1, &argv[1]);
5726+
goto out;
5727+
}
57245728

57255729
/* Using just --errno-summary will trigger --summary */
57265730
if (trace.errno_summary && !trace.summary && !trace.summary_only)

0 commit comments

Comments
 (0)