From: David Ahern <dsahern@gmail.com>
To: acme@ghostprotocols.net, linux-kernel@vger.kernel.org
Cc: David Ahern <dsahern@gmail.com>, Ingo Molnar <mingo@kernel.org>,
Frederic Weisbecker <fweisbec@gmail.com>,
Peter Zijlstra <peterz@infradead.org>,
Jiri Olsa <jolsa@redhat.com>, Namhyung Kim <namhyung@kernel.org>
Subject: [PATCH 3/6] perf event: initialize allocated memory for synthesized events
Date: Tue, 2 Jul 2013 13:27:22 -0600 [thread overview]
Message-ID: <1372793245-4136-4-git-send-email-dsahern@gmail.com> (raw)
In-Reply-To: <1372793245-4136-1-git-send-email-dsahern@gmail.com>
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@gmail.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
---
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;
--
1.7.10.1
next prev parent reply other threads:[~2013-07-02 19:41 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-07-02 19:27 [PATCH 0/6] perf: bug fixes, cleanup of parse events memory allocations David Ahern
2013-07-02 19:27 ` [PATCH 1/6] perf evsel: fix count parameter to read call in event_format__new David Ahern
2013-07-12 8:51 ` [tip:perf/urgent] perf evsel: Fix " tip-bot for David Ahern
2013-07-02 19:27 ` [PATCH 2/6] perf evlist: fix use of uninitialized variable David Ahern
2013-07-19 7:44 ` [tip:perf/core] perf evlist: Fix " tip-bot for David Ahern
2013-07-02 19:27 ` David Ahern [this message]
2013-07-11 16:35 ` [PATCH 3/6] perf event: initialize allocated memory for synthesized events David Ahern
2013-07-02 19:27 ` [PATCH 4/6] perf: don't free list head in parse_events__free_terms David Ahern
2013-07-19 7:45 ` [tip:perf/core] perf tools: Don' t " tip-bot for David Ahern
2013-07-02 19:27 ` [PATCH 5/6] perf test: make terms a stack variable in test_term David Ahern
2013-07-19 7:45 ` [tip:perf/core] perf tests: Make " tip-bot for David Ahern
2013-07-02 19:27 ` [PATCH 6/6] perf parse events: demystify memory allocations David Ahern
2013-07-07 15:26 ` Jiri Olsa
2013-07-07 16:45 ` David Ahern
2013-07-07 17:00 ` Jiri Olsa
2013-07-19 7:45 ` [tip:perf/core] perf parse events: Demystify " tip-bot for David Ahern
2013-07-05 14:34 ` [PATCH 0/6] perf: bug fixes, cleanup of parse events " Arnaldo Carvalho de Melo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1372793245-4136-4-git-send-email-dsahern@gmail.com \
--to=dsahern@gmail.com \
--cc=acme@ghostprotocols.net \
--cc=fweisbec@gmail.com \
--cc=jolsa@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=namhyung@kernel.org \
--cc=peterz@infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox