Re: [PATCH 3/6] perf event: initialize allocated memory for synthesizedevents

From: David Ahern
Date: Thu Jul 11 2013 - 12:36:10 EST


Arnaldo:

Don't see this one in your perf/core branch.

On 7/2/13 1:27 PM, David Ahern wrote:
Fixes valgrind complaint:

=3118== Syscall param write(buf) points to uninitialised byte(s)
==3118== at 0x4E3F5B0: __write_nocancel (in /lib64/libpthread-2.14.90.so)
==3118== by 0x42F0EB: process_synthesized_event (builtin-record.c:89)
==3118== by 0x44E81C: perf_event__synthesize_mmap_events (event.c:230)
==3118== by 0x44F27C: perf_event__synthesize_threads (event.c:307)
==3118== by 0x42FEEA: cmd_record (builtin-record.c:530)
==3118== by 0x419D22: run_builtin (perf.c:319)
==3118== by 0x4195A2: main (perf.c:376)

Signed-off-by: David Ahern <dsahern@xxxxxxxxx>
Cc: Ingo Molnar <mingo@xxxxxxxxxx>
Cc: Frederic Weisbecker <fweisbec@xxxxxxxxx>
Cc: Peter Zijlstra <peterz@xxxxxxxxxxxxx>
Cc: Jiri Olsa <jolsa@xxxxxxxxxx>
Cc: Namhyung Kim <namhyung@xxxxxxxxxx>
---
tools/perf/util/event.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/tools/perf/util/event.c b/tools/perf/util/event.c
index 5cd13d7..556b999 100644
--- a/tools/perf/util/event.c
+++ b/tools/perf/util/event.c
@@ -316,11 +316,11 @@ int perf_event__synthesize_thread_map(struct perf_tool *tool,
union perf_event *comm_event, *mmap_event;
int err = -1, thread, j;

- comm_event = malloc(sizeof(comm_event->comm) + machine->id_hdr_size);
+ comm_event = zalloc(sizeof(comm_event->comm) + machine->id_hdr_size);
if (comm_event == NULL)
goto out;

- mmap_event = malloc(sizeof(mmap_event->mmap) + machine->id_hdr_size);
+ mmap_event = zalloc(sizeof(mmap_event->mmap) + machine->id_hdr_size);
if (mmap_event == NULL)
goto out_free_comm;

@@ -375,11 +375,11 @@ int perf_event__synthesize_threads(struct perf_tool *tool,
union perf_event *comm_event, *mmap_event;
int err = -1;

- comm_event = malloc(sizeof(comm_event->comm) + machine->id_hdr_size);
+ comm_event = zalloc(sizeof(comm_event->comm) + machine->id_hdr_size);
if (comm_event == NULL)
goto out;

- mmap_event = malloc(sizeof(mmap_event->mmap) + machine->id_hdr_size);
+ mmap_event = zalloc(sizeof(mmap_event->mmap) + machine->id_hdr_size);
if (mmap_event == NULL)
goto out_free_comm;



--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/