提交 b0fb978e 编写于 作者: W Wang Nan 提交者: Arnaldo Carvalho de Melo

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: NWang Nan <wangnan0@huawei.com>
Reviewed-by: NMasami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Acked-by: NJiri 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.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
上级 8a59f3cc
...@@ -503,7 +503,7 @@ int perf_event__synthesize_thread_map(struct perf_tool *tool, ...@@ -503,7 +503,7 @@ int perf_event__synthesize_thread_map(struct perf_tool *tool,
if (comm_event == NULL) if (comm_event == NULL)
goto out; goto out;
mmap_event = malloc(sizeof(mmap_event->mmap) + machine->id_hdr_size); mmap_event = malloc(sizeof(mmap_event->mmap2) + machine->id_hdr_size);
if (mmap_event == NULL) if (mmap_event == NULL)
goto out_free_comm; goto out_free_comm;
...@@ -577,7 +577,7 @@ int perf_event__synthesize_threads(struct perf_tool *tool, ...@@ -577,7 +577,7 @@ int perf_event__synthesize_threads(struct perf_tool *tool,
if (comm_event == NULL) if (comm_event == NULL)
goto out; goto out;
mmap_event = malloc(sizeof(mmap_event->mmap) + machine->id_hdr_size); mmap_event = malloc(sizeof(mmap_event->mmap2) + machine->id_hdr_size);
if (mmap_event == NULL) if (mmap_event == NULL)
goto out_free_comm; goto out_free_comm;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册