diff options
author | Wang Nan <wangnan0@huawei.com> | 2016-01-12 05:12:04 -0500 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2016-01-12 09:24:43 -0500 |
commit | b0fb978e97f58ca930f7cafc4ddc264218710765 (patch) | |
tree | c6cd7445562342d75a2340163f1ae77e6c2fcbfc /tools | |
parent | 8a59f3ccbc11fcb222b046a64929dd473f7dff54 (diff) |
perf tools: Fix mmap2 event allocation in synthesize code
perf_event__synthesize_mmap_events() issues mmap2 events, but the memory
of that event is allocated using:
mmap_event = malloc(sizeof(mmap_event->mmap) + machine->id_hdr_size);
If path of mmap source file is long (near PATH_MAX), random crash would
happen. Should use sizeof(mmap_event->mmap2).
Fix two memory allocations.
Signed-off-by: Wang Nan <wangnan0@huawei.com>
Reviewed-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Cc: He Kuang <hekuang@huawei.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Zefan Li <lizefan@huawei.com>
Cc: pi3orama@163.com
Link: http://lkml.kernel.org/r/1452593524-138970-1-git-send-email-wangnan0@huawei.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/perf/util/event.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/tools/perf/util/event.c b/tools/perf/util/event.c index cd61bb1f3917..85155e91b61b 100644 --- a/tools/perf/util/event.c +++ b/tools/perf/util/event.c | |||
@@ -503,7 +503,7 @@ int perf_event__synthesize_thread_map(struct perf_tool *tool, | |||
503 | if (comm_event == NULL) | 503 | if (comm_event == NULL) |
504 | goto out; | 504 | goto out; |
505 | 505 | ||
506 | mmap_event = malloc(sizeof(mmap_event->mmap) + machine->id_hdr_size); | 506 | mmap_event = malloc(sizeof(mmap_event->mmap2) + machine->id_hdr_size); |
507 | if (mmap_event == NULL) | 507 | if (mmap_event == NULL) |
508 | goto out_free_comm; | 508 | goto out_free_comm; |
509 | 509 | ||
@@ -577,7 +577,7 @@ int perf_event__synthesize_threads(struct perf_tool *tool, | |||
577 | if (comm_event == NULL) | 577 | if (comm_event == NULL) |
578 | goto out; | 578 | goto out; |
579 | 579 | ||
580 | mmap_event = malloc(sizeof(mmap_event->mmap) + machine->id_hdr_size); | 580 | mmap_event = malloc(sizeof(mmap_event->mmap2) + machine->id_hdr_size); |
581 | if (mmap_event == NULL) | 581 | if (mmap_event == NULL) |
582 | goto out_free_comm; | 582 | goto out_free_comm; |
583 | 583 | ||