diff options
author | He Kuang <hekuang@huawei.com> | 2015-03-04 05:01:42 -0500 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2015-03-12 11:39:58 -0400 |
commit | a78604defffbc1da1497a8c8b48275b723eb5946 (patch) | |
tree | 8441c534c130a9d0f4ffdcbf49195b89a73d025b /tools | |
parent | 443a70541c56d4a7dff0ce693870935e138201b2 (diff) |
perf probe: Fix possible double free on error
A double free occurred when get source file path failed. If lr->path
failed to assign a new value, it will be freed as the old path and then
be freed again during line_range__clear(), and causes this:
$ perf probe -L do_execve -k vmlinux
*** Error in `/usr/bin/perf': double free or corruption (fasttop):
0x0000000000a9ac50 ***
======= Backtrace: =========
../lib64/libc.so.6(+0x6eeef)[0x7ffff5e44eef]
../lib64/libc.so.6(+0x78cae)[0x7ffff5e4ecae]
../lib64/libc.so.6(+0x79987)[0x7ffff5e4f987]
../bin/perf[0x4ab41f]
...
This patch fix this problem.
Signed-off-by: He Kuang <hekuang@huawei.com>
Acked-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/r/1425463302-1687-1-git-send-email-hekuang@huawei.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/perf/util/probe-event.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c index 8af8e7f55254..e2bf620f98cb 100644 --- a/tools/perf/util/probe-event.c +++ b/tools/perf/util/probe-event.c | |||
@@ -790,7 +790,11 @@ static int __show_line_range(struct line_range *lr, const char *module, | |||
790 | /* Convert source file path */ | 790 | /* Convert source file path */ |
791 | tmp = lr->path; | 791 | tmp = lr->path; |
792 | ret = get_real_path(tmp, lr->comp_dir, &lr->path); | 792 | ret = get_real_path(tmp, lr->comp_dir, &lr->path); |
793 | free(tmp); /* Free old path */ | 793 | |
794 | /* Free old path when new path is assigned */ | ||
795 | if (tmp != lr->path) | ||
796 | free(tmp); | ||
797 | |||
794 | if (ret < 0) { | 798 | if (ret < 0) { |
795 | pr_warning("Failed to find source file path.\n"); | 799 | pr_warning("Failed to find source file path.\n"); |
796 | return ret; | 800 | return ret; |