Skip to content

Commit 8bde851

Browse files
changbinduacmel
authored andcommitted
perf build-id: Fix memory leak in print_sdt_events()
Detected with gcc's ASan: Direct leak of 4356 byte(s) in 120 object(s) allocated from: #0 0x7ff1a2b5a070 in __interceptor_strdup (/usr/lib/x86_64-linux-gnu/libasan.so.5+0x3b070) #1 0x55719aef4814 in build_id_cache__origname util/build-id.c:215 raspberrypi#2 0x55719af649b6 in print_sdt_events util/parse-events.c:2339 raspberrypi#3 0x55719af66272 in print_events util/parse-events.c:2542 raspberrypi#4 0x55719ad1ecaa in cmd_list /home/changbin/work/linux/tools/perf/builtin-list.c:58 raspberrypi#5 0x55719aec745d in run_builtin /home/changbin/work/linux/tools/perf/perf.c:302 raspberrypi#6 0x55719aec7d1a in handle_internal_command /home/changbin/work/linux/tools/perf/perf.c:354 raspberrypi#7 0x55719aec8184 in run_argv /home/changbin/work/linux/tools/perf/perf.c:398 raspberrypi#8 0x55719aeca41a in main /home/changbin/work/linux/tools/perf/perf.c:520 raspberrypi#9 0x7ff1a07ae09a in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2409a) Signed-off-by: Changbin Du <[email protected]> Reviewed-by: Jiri Olsa <[email protected]> Cc: Alexei Starovoitov <[email protected]> Cc: Daniel Borkmann <[email protected]> Cc: Masami Hiramatsu <[email protected]> Cc: Namhyung Kim <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Steven Rostedt (VMware) <[email protected]> Fixes: 40218da ("perf list: Show SDT and pre-cached events") Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
1 parent 54569ba commit 8bde851

File tree

2 files changed

+2
-0
lines changed

2 files changed

+2
-0
lines changed

tools/perf/util/build-id.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,7 @@ char *build_id_cache__linkname(const char *sbuild_id, char *bf, size_t size)
185185
return bf;
186186
}
187187

188+
/* The caller is responsible to free the returned buffer. */
188189
char *build_id_cache__origname(const char *sbuild_id)
189190
{
190191
char *linkname;

tools/perf/util/parse-events.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2342,6 +2342,7 @@ void print_sdt_events(const char *subsys_glob, const char *event_glob,
23422342
printf(" %-50s [%s]\n", buf, "SDT event");
23432343
free(buf);
23442344
}
2345+
free(path);
23452346
} else
23462347
printf(" %-50s [%s]\n", nd->s, "SDT event");
23472348
if (nd2) {

0 commit comments

Comments
 (0)