From: tip-bot for Masami Hiramatsu <tipbot@zytor.com>
To: linux-tip-commits@vger.kernel.org
Cc: wangnan0@huawei.com, hpa@zytor.com,
masami.hiramatsu.pt@hitachi.com, mingo@kernel.org,
linux-kernel@vger.kernel.org, tglx@linutronix.de, ast@kernel.org,
lizefan@huawei.com, acme@redhat.com
Subject: [tip:perf/urgent] perf probe: Fix memory leaking on failure by clearing all probe_trace_events
Date: Tue, 17 Nov 2015 22:19:38 -0800 [thread overview]
Message-ID: <tip-0196e787ceb58cdfea822482ec70019bc16cbd51@git.kernel.org> (raw)
In-Reply-To: <1447417761-156094-2-git-send-email-wangnan0@huawei.com>
Commit-ID: 0196e787ceb58cdfea822482ec70019bc16cbd51
Gitweb: http://git.kernel.org/tip/0196e787ceb58cdfea822482ec70019bc16cbd51
Author: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
AuthorDate: Fri, 13 Nov 2015 12:29:10 +0000
Committer: Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Fri, 13 Nov 2015 12:24:32 -0300
perf probe: Fix memory leaking on failure by clearing all probe_trace_events
Fix memory leaking on the debuginfo__find_trace_events() failure path
which frees an array of probe_trace_events but doesn't clears all the
allocated sub-structures and strings.
So, before doing zfree(tevs), clear all the array elements which may
have allocated resources.
Reported-by: Wang Nan <wangnan0@huawei.com>
Signed-off-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Cc: Alexei Starovoitov <ast@kernel.org>
Cc: Zefan Li <lizefan@huawei.com>
Cc: pi3orama@163.com
Link: http://lkml.kernel.org/r/1447417761-156094-2-git-send-email-wangnan0@huawei.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/perf/util/probe-finder.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/tools/perf/util/probe-finder.c b/tools/perf/util/probe-finder.c
index bd8f03d..63993d7 100644
--- a/tools/perf/util/probe-finder.c
+++ b/tools/perf/util/probe-finder.c
@@ -1246,7 +1246,7 @@ int debuginfo__find_trace_events(struct debuginfo *dbg,
struct trace_event_finder tf = {
.pf = {.pev = pev, .callback = add_probe_trace_event},
.max_tevs = probe_conf.max_probes, .mod = dbg->mod};
- int ret;
+ int ret, i;
/* Allocate result tevs array */
*tevs = zalloc(sizeof(struct probe_trace_event) * tf.max_tevs);
@@ -1258,6 +1258,8 @@ int debuginfo__find_trace_events(struct debuginfo *dbg,
ret = debuginfo__find_probes(dbg, &tf.pf);
if (ret < 0) {
+ for (i = 0; i < tf.ntevs; i++)
+ clear_probe_trace_event(&tf.tevs[i]);
zfree(tevs);
return ret;
}
next prev parent reply other threads:[~2015-11-18 6:20 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-11-13 12:29 [PATCH 00/12] perf tools: bpf: Improve BPF program ability Wang Nan
2015-11-13 12:29 ` [PATCH 01/12] perf probe: Fix memory leaking on faiulre by clearing all probe_trace_events Wang Nan
2015-11-18 6:19 ` tip-bot for Masami Hiramatsu [this message]
2015-11-13 12:29 ` [PATCH 02/12] perf probe: Clear probe_trace_event when add_probe_trace_event() fails Wang Nan
2015-11-13 15:50 ` Arnaldo Carvalho de Melo
2015-11-18 6:19 ` [tip:perf/urgent] " tip-bot for Wang Nan
2015-11-13 12:29 ` [PATCH 03/12] perf tools: Allow BPF program attach to uprobe events Wang Nan
2015-11-13 15:39 ` Arnaldo Carvalho de Melo
2015-11-13 12:29 ` [PATCH 04/12] perf tools: Allow BPF program attach to modules Wang Nan
2015-11-13 15:40 ` Arnaldo Carvalho de Melo
2015-11-13 12:29 ` [PATCH 05/12] perf tools: Allow BPF program config probing options Wang Nan
2015-11-13 15:46 ` Arnaldo Carvalho de Melo
2015-11-16 9:11 ` Wangnan (F)
2015-11-13 12:29 ` [PATCH 06/12] bpf tools: Load a program with different instances using preprocessor Wang Nan
2015-11-13 12:29 ` [PATCH 07/12] perf tools: Add BPF_PROLOGUE config options for further patches Wang Nan
2015-11-13 12:29 ` [PATCH 08/12] perf tools: Compile dwarf-regs.c if CONFIG_BPF_PROLOGUE is on Wang Nan
2015-11-13 12:29 ` [PATCH 09/12] perf tools: Add prologue for BPF programs for fetching arguments Wang Nan
2015-11-13 12:29 ` [PATCH 10/12] perf tools: Generate prologue for BPF programs Wang Nan
2015-11-13 12:29 ` [PATCH 11/12] perf test: Test BPF prologue Wang Nan
2015-11-13 12:29 ` [PATCH 12/12] perf tools: Use same BPF program if arguments are identical Wang Nan
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-0196e787ceb58cdfea822482ec70019bc16cbd51@git.kernel.org \
--to=tipbot@zytor.com \
--cc=acme@redhat.com \
--cc=ast@kernel.org \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tip-commits@vger.kernel.org \
--cc=lizefan@huawei.com \
--cc=masami.hiramatsu.pt@hitachi.com \
--cc=mingo@kernel.org \
--cc=tglx@linutronix.de \
--cc=wangnan0@huawei.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