Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
fork

Configure Feed

Select the types of activity you want to include in your feed.

perf trace: Free syscall->arg_fmt

ASan reports several memory leaks running:

# perf test "88: Check open filename arg using perf trace + vfs_getname"

The second of these leaks is caused by the arg_fmt field of syscall not
being deallocated.

This patch adds a new function syscall__exit which is called on all
syscalls.table entries in trace__exit, which will free the arg_fmt
field.

Signed-off-by: Riccardo Mancini <rickyman7@gmail.com>
Cc: Ian Rogers <irogers@google.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lore.kernel.org/lkml/d68f25c043d30464ac9fa79c3399e18f429bca82.1626343282.git.rickyman7@gmail.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by

Riccardo Mancini and committed by
Arnaldo Carvalho de Melo
f2ebf8ff 6c7f0ab0

+15 -1
+15 -1
tools/perf/builtin-trace.c
··· 2266 2266 return augmented_args; 2267 2267 } 2268 2268 2269 + static void syscall__exit(struct syscall *sc) 2270 + { 2271 + if (!sc) 2272 + return; 2273 + 2274 + free(sc->arg_fmt); 2275 + } 2276 + 2269 2277 static int trace__sys_enter(struct trace *trace, struct evsel *evsel, 2270 2278 union perf_event *event __maybe_unused, 2271 2279 struct perf_sample *sample) ··· 4711 4703 4712 4704 static void trace__exit(struct trace *trace) 4713 4705 { 4706 + int i; 4707 + 4714 4708 strlist__delete(trace->ev_qualifier); 4715 4709 free(trace->ev_qualifier_ids.entries); 4716 - free(trace->syscalls.table); 4710 + if (trace->syscalls.table) { 4711 + for (i = 0; i <= trace->sctbl->syscalls.max_id; i++) 4712 + syscall__exit(&trace->syscalls.table[i]); 4713 + free(trace->syscalls.table); 4714 + } 4717 4715 syscalltbl__delete(trace->sctbl); 4718 4716 zfree(&trace->perfconfig_events); 4719 4717 }