Message ID | 1452593524-138970-1-git-send-email-wangnan0@huawei.com |
---|---|
State | Accepted |
Commit | b0fb978e97f58ca930f7cafc4ddc264218710765 |
Headers | show |
On 2016/1/12 18:49, 平松雅巳 / HIRAMATU,MASAMI wrote: >> From: Wang Nan [mailto:wangnan0@huawei.com] >> >> 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. > Looks good to me. But hope to have another rename patch soon after this... According to Arnaldo, we don't need rename patch. He think mmap_event is okay. Right? Thank you.
diff --git a/tools/perf/util/event.c b/tools/perf/util/event.c index cd61bb1..85155e9 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, if (comm_event == NULL) 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) goto out_free_comm; @@ -577,7 +577,7 @@ int perf_event__synthesize_threads(struct perf_tool *tool, if (comm_event == NULL) 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) goto out_free_comm;