From: tip-bot for Masami Hiramatsu <tipbot@zytor.com>
To: linux-tip-commits@vger.kernel.org
Cc: acme@redhat.com, linux-kernel@vger.kernel.org, mingo@redhat.com,
dave.long@linaro.org, hpa@zytor.com, mingo@kernel.org,
namhyung@kernel.org, masami.hiramatsu.pt@hitachi.com,
rostedt@goodmis.org, srikar@linux.vnet.ibm.com,
dsahern@gmail.com, oleg@redhat.com, tglx@linutronix.de
Subject: [tip:perf/core] perf probe: Release allocated probe_trace_event if failed
Date: Sun, 19 Jan 2014 04:24:39 -0800 [thread overview]
Message-ID: <tip-981d05adf2e2acc328abb929a6ed3536c0d41c5f@git.kernel.org> (raw)
In-Reply-To: <20140116093944.24403.30228.stgit@kbuild-fedora.novalocal>
Commit-ID: 981d05adf2e2acc328abb929a6ed3536c0d41c5f
Gitweb: http://git.kernel.org/tip/981d05adf2e2acc328abb929a6ed3536c0d41c5f
Author: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
AuthorDate: Thu, 16 Jan 2014 09:39:44 +0000
Committer: Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Thu, 16 Jan 2014 16:26:50 -0300
perf probe: Release allocated probe_trace_event if failed
To fix a memory leak, release all allocated probe_trace_event on the
error path of try_to_find_probe_trace_events.
Reported-by: David Ahern <dsahern@gmail.com>
Signed-off-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Cc: "David A. Long" <dave.long@linaro.org>
Cc: "Steven Rostedt (Red Hat)" <rostedt@goodmis.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Oleg Nesterov <oleg@redhat.com>
Cc: Srikar Dronamraju <srikar@linux.vnet.ibm.com>
Cc: yrl.pp-manager.tt@hitachi.com
Link: http://lkml.kernel.org/r/20140116093944.24403.30228.stgit@kbuild-fedora.novalocal
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/perf/util/probe-event.c | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c
index a4ee6b4..579b655 100644
--- a/tools/perf/util/probe-event.c
+++ b/tools/perf/util/probe-event.c
@@ -72,6 +72,7 @@ static int e_snprintf(char *str, size_t size, const char *format, ...)
static char *synthesize_perf_probe_point(struct perf_probe_point *pp);
static int convert_name_to_addr(struct perf_probe_event *pev,
const char *exec);
+static void clear_probe_trace_event(struct probe_trace_event *tev);
static struct machine machine;
/* Initialize symbol maps and path of vmlinux/modules */
@@ -407,6 +408,14 @@ static int add_module_to_probe_trace_events(struct probe_trace_event *tevs,
return ret;
}
+static void clear_probe_trace_events(struct probe_trace_event *tevs, int ntevs)
+{
+ int i;
+
+ for (i = 0; i < ntevs; i++)
+ clear_probe_trace_event(tevs + i);
+}
+
/* Try to find perf_probe_event with debuginfo */
static int try_to_find_probe_trace_events(struct perf_probe_event *pev,
struct probe_trace_event **tevs,
@@ -442,6 +451,10 @@ static int try_to_find_probe_trace_events(struct perf_probe_event *pev,
ret = add_module_to_probe_trace_events(*tevs,
ntevs, target);
}
+ if (ret < 0) {
+ clear_probe_trace_events(*tevs, ntevs);
+ zfree(tevs);
+ }
return ret < 0 ? ret : ntevs;
}
next prev parent reply other threads:[~2014-01-19 12:25 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-01-16 9:39 [PATCH -tip 0/3] perf-probe bugfixes Masami Hiramatsu
2014-01-16 9:39 ` [PATCH -tip 1/3] [BUGFIX] perf-probe: Release allocated probe_trace_event if failed Masami Hiramatsu
2014-01-19 12:24 ` tip-bot for Masami Hiramatsu [this message]
2014-01-16 9:39 ` [PATCH -tip 2/3] [BUGFIX] perf-probe: Release all dynamically allocated parameters Masami Hiramatsu
2014-01-19 12:24 ` [tip:perf/core] perf probe: " tip-bot for Masami Hiramatsu
2014-01-16 9:39 ` [PATCH -tip 3/3] [CLEANUP] perf-tools: Export elf_section_by_name and reuse Masami Hiramatsu
2014-01-19 12:24 ` [tip:perf/core] perf symbols: " tip-bot for Masami Hiramatsu
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=tip-981d05adf2e2acc328abb929a6ed3536c0d41c5f@git.kernel.org \
--to=tipbot@zytor.com \
--cc=acme@redhat.com \
--cc=dave.long@linaro.org \
--cc=dsahern@gmail.com \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tip-commits@vger.kernel.org \
--cc=masami.hiramatsu.pt@hitachi.com \
--cc=mingo@kernel.org \
--cc=mingo@redhat.com \
--cc=namhyung@kernel.org \
--cc=oleg@redhat.com \
--cc=rostedt@goodmis.org \
--cc=srikar@linux.vnet.ibm.com \
--cc=tglx@linutronix.de \
/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
Powered by JetHome