From: Namhyung Kim <namhyung@kernel.org>
To: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>,
Paul Mackerras <paulus@samba.org>, Ingo Molnar <mingo@kernel.org>,
Namhyung Kim <namhyung.kim@lge.com>,
LKML <linux-kernel@vger.kernel.org>, Jiri Olsa <jolsa@redhat.com>
Subject: [PATCH 2/2] perf header: Fix possible memory leaks in process_group_desc()
Date: Mon, 18 Nov 2013 11:20:44 +0900 [thread overview]
Message-ID: <1384741244-7271-2-git-send-email-namhyung@kernel.org> (raw)
In-Reply-To: <1384741244-7271-1-git-send-email-namhyung@kernel.org>
From: Namhyung Kim <namhyung.kim@lge.com>
After processing all group descriptors or encountering an error, it
frees all descriptors. However, current logic can leak memory since
it might not traverse all descriptors.
Note that the 'i' can have different value than nr_groups when an
error occurred and it's safe to call free(desc[i].name) for every desc
since we already make it NULL when it's reused for group names.
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
---
| 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
--git a/tools/perf/util/header.c b/tools/perf/util/header.c
index 559c516f1cec..1cd035708931 100644
--- a/tools/perf/util/header.c
+++ b/tools/perf/util/header.c
@@ -2107,7 +2107,7 @@ static int process_group_desc(struct perf_file_section *section __maybe_unused,
ret = 0;
out_free:
- while ((int) --i >= 0)
+ for (i = 0; i < nr_groups; i++)
free(desc[i].name);
free(desc);
--
1.7.11.7
next prev parent reply other threads:[~2013-11-18 2:21 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-11-18 2:20 [PATCH 1/2] perf header: Fix bogus group name Namhyung Kim
2013-11-18 2:20 ` Namhyung Kim [this message]
2013-11-20 13:55 ` [tip:perf/urgent] perf header: Fix possible memory leaks in process_group_desc() tip-bot for Namhyung Kim
2013-11-20 13:55 ` [tip:perf/urgent] perf header: Fix bogus group name tip-bot for Namhyung Kim
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=1384741244-7271-2-git-send-email-namhyung@kernel.org \
--to=namhyung@kernel.org \
--cc=a.p.zijlstra@chello.nl \
--cc=acme@ghostprotocols.net \
--cc=jolsa@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=namhyung.kim@lge.com \
--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