Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932367AbbKRGUB (ORCPT ); Wed, 18 Nov 2015 01:20:01 -0500 Received: from terminus.zytor.com ([198.137.202.10]:50196 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932077AbbKRGT6 (ORCPT ); Wed, 18 Nov 2015 01:19:58 -0500 Date: Tue, 17 Nov 2015 22:19:38 -0800 From: tip-bot for Masami Hiramatsu Message-ID: 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 Reply-To: lizefan@huawei.com, ast@kernel.org, tglx@linutronix.de, acme@redhat.com, masami.hiramatsu.pt@hitachi.com, wangnan0@huawei.com, hpa@zytor.com, linux-kernel@vger.kernel.org, mingo@kernel.org In-Reply-To: <1447417761-156094-2-git-send-email-wangnan0@huawei.com> References: <1447417761-156094-2-git-send-email-wangnan0@huawei.com> To: linux-tip-commits@vger.kernel.org Subject: [tip:perf/urgent] perf probe: Fix memory leaking on failure by clearing all probe_trace_events Git-Commit-ID: 0196e787ceb58cdfea822482ec70019bc16cbd51 X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2171 Lines: 54 Commit-ID: 0196e787ceb58cdfea822482ec70019bc16cbd51 Gitweb: http://git.kernel.org/tip/0196e787ceb58cdfea822482ec70019bc16cbd51 Author: Masami Hiramatsu AuthorDate: Fri, 13 Nov 2015 12:29:10 +0000 Committer: Arnaldo Carvalho de Melo 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 Signed-off-by: Masami Hiramatsu Cc: Alexei Starovoitov Cc: Zefan Li 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 --- 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; } -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/