From: Arnaldo Carvalho de Melo <acme@infradead.org>
To: Ingo Molnar <mingo@elte.hu>
Cc: linux-kernel@vger.kernel.org,
Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>,
Peter Zijlstra <a.p.zijlstra@chello.nl>,
Paul Mackerras <paulus@samba.org>, Ingo Molnar <mingo@elte.hu>,
Arnaldo Carvalho de Melo <acme@redhat.com>
Subject: [PATCH 2/4] perf probe: Fix memory leaks in add_perf_probe_events
Date: Fri, 6 Aug 2010 22:34:07 -0300 [thread overview]
Message-ID: <1281144849-22896-3-git-send-email-acme@infradead.org> (raw)
In-Reply-To: <1281144849-22896-1-git-send-email-acme@infradead.org>
From: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Fix several memory leaks of pkgs and tevs in add_perf_probe_events().
Reported-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: linux-kernel@vger.kernel.org
LKML-Reference: <4C577ADC.1000309@hitachi.com>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/perf/util/probe-event.c | 11 ++++++++---
1 files changed, 8 insertions(+), 3 deletions(-)
diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c
index 2e665cb..e72f05c 100644
--- a/tools/perf/util/probe-event.c
+++ b/tools/perf/util/probe-event.c
@@ -1606,8 +1606,10 @@ int add_perf_probe_events(struct perf_probe_event *pevs, int npevs,
/* Init vmlinux path */
ret = init_vmlinux();
- if (ret < 0)
+ if (ret < 0) {
+ free(pkgs);
return ret;
+ }
/* Loop 1: convert all events */
for (i = 0; i < npevs; i++) {
@@ -1625,10 +1627,13 @@ int add_perf_probe_events(struct perf_probe_event *pevs, int npevs,
ret = __add_probe_trace_events(pkgs[i].pev, pkgs[i].tevs,
pkgs[i].ntevs, force_add);
end:
- /* Loop 3: cleanup trace events */
- for (i = 0; i < npevs; i++)
+ /* Loop 3: cleanup and free trace events */
+ for (i = 0; i < npevs; i++) {
for (j = 0; j < pkgs[i].ntevs; j++)
clear_probe_trace_event(&pkgs[i].tevs[j]);
+ free(pkgs[i].tevs);
+ }
+ free(pkgs);
return ret;
}
--
1.6.2.5
next prev parent reply other threads:[~2010-08-07 1:34 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-08-07 1:34 [GIT PULL 0/4] perf/core fixes and improvements Arnaldo Carvalho de Melo
2010-08-07 1:34 ` [PATCH 1/4] perf probe: Fix to copy the type for raw parameters Arnaldo Carvalho de Melo
2010-08-07 1:34 ` Arnaldo Carvalho de Melo [this message]
2010-08-07 1:34 ` [PATCH 3/4] perf tui: Introduce list_head based generic ui_browser refresh routine Arnaldo Carvalho de Melo
2010-08-07 1:34 ` [PATCH 4/4] perf ui: Start breaking down newt.c into multiple files Arnaldo Carvalho de Melo
2010-08-07 6:43 ` [GIT PULL 0/4] perf/core fixes and improvements Ingo Molnar
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=1281144849-22896-3-git-send-email-acme@infradead.org \
--to=acme@infradead.org \
--cc=a.p.zijlstra@chello.nl \
--cc=acme@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=masami.hiramatsu.pt@hitachi.com \
--cc=mingo@elte.hu \
--cc=paulus@samba.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;
as well as URLs for NNTP newsgroup(s).