lkml.org 
[lkml]   [2016]   [Jan]   [12]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
SubjectRE: [PATCH 16/53 v2] perf tools: Fix mmap2 event allocation in synthesize code
Date
>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...

Reviewed-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>

Thanks,

>
>Signed-off-by: Wang Nan <wangnan0@huawei.com>
>Acked-by: Jiri Olsa <jolsa@kernel.org>
>Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
>Cc: He Kuang <hekuang@huawei.com>
>Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
>Cc: Namhyung Kim <namhyung@kernel.org>
>Cc: Zefan Li <lizefan@huawei.com>
>Cc: pi3orama@163.com
>---
>
>v1 -> v2: Don't rename mmap to mmap2.
>
>---
> tools/perf/util/event.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
>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;
>
>--
>1.8.3.4

\
 
 \ /
  Last update: 2016-01-12 12:41    [W:0.162 / U:0.472 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site