From: Arnaldo Carvalho de Melo <acme@infradead.org>
To: Ingo Molnar <mingo@elte.hu>
Cc: linux-kernel@vger.kernel.org,
"Arnaldo Carvalho de Melo" <acme@redhat.com>,
"Frédéric Weisbecker" <fweisbec@gmail.com>,
"Mike Galbraith" <efault@gmx.de>,
"Paul Mackerras" <paulus@samba.org>,
"Peter Zijlstra" <a.p.zijlstra@chello.nl>,
"Tom Zanussi" <tzanussi@gmail.com>
Subject: [PATCH 2/3] perf report: Fix leak of resolved callchains array on error path
Date: Sun, 9 May 2010 13:14:56 -0300 [thread overview]
Message-ID: <1273421697-30138-3-git-send-email-acme@infradead.org> (raw)
In-Reply-To: <1273421697-30138-1-git-send-email-acme@infradead.org>
From: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Frédéric Weisbecker <fweisbec@gmail.com>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Tom Zanussi <tzanussi@gmail.com>
LKML-Reference: <new-submission>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/perf/builtin-report.c | 16 +++++++---------
1 files changed, 7 insertions(+), 9 deletions(-)
diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c
index 1cae877..3a70c58 100644
--- a/tools/perf/builtin-report.c
+++ b/tools/perf/builtin-report.c
@@ -83,7 +83,7 @@ static int perf_session__add_hist_entry(struct perf_session *self,
struct map_symbol *syms = NULL;
struct symbol *parent = NULL;
bool hit;
- int err;
+ int err = -ENOMEM;
struct hist_entry *he;
struct event_stat_id *stats;
struct perf_event_attr *attr;
@@ -101,26 +101,24 @@ static int perf_session__add_hist_entry(struct perf_session *self,
else
stats = get_stats(self, data->id, 0, 0);
if (stats == NULL)
- return -ENOMEM;
+ goto out_free_syms;
he = __perf_session__add_hist_entry(&stats->hists, al, parent,
data->period, &hit);
if (he == NULL)
- return -ENOMEM;
+ goto out_free_syms;
if (hit)
__perf_session__add_count(he, al, data->period);
+ err = 0;
if (symbol_conf.use_callchain) {
if (!hit)
callchain_init(he->callchain);
err = append_chain(he->callchain, data->callchain, syms);
- free(syms);
-
- if (err)
- return err;
}
-
- return 0;
+out_free_syms:
+ free(syms);
+ return err;
}
static int add_event_total(struct perf_session *session,
--
1.6.2.5
next prev parent reply other threads:[~2010-05-09 16:15 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-05-09 16:14 [PATCH 0/3] perf tools minor fixes Arnaldo Carvalho de Melo
2010-05-09 16:14 ` [PATCH 1/3] perf callchain: Move validate_callchain to callchain lib Arnaldo Carvalho de Melo
2010-05-09 16:14 ` Arnaldo Carvalho de Melo [this message]
2010-05-09 16:14 ` [PATCH 3/3] perf hist: Simplify the insertion of new hist_entry instances Arnaldo Carvalho de Melo
2010-05-09 17:48 ` [PATCH 0/3] perf tools minor fixes 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=1273421697-30138-3-git-send-email-acme@infradead.org \
--to=acme@infradead.org \
--cc=a.p.zijlstra@chello.nl \
--cc=acme@redhat.com \
--cc=efault@gmx.de \
--cc=fweisbec@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=paulus@samba.org \
--cc=tzanussi@gmail.com \
/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
all inboxes | Powered by JetHome®