lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <tip-b7b75a60b291cc699ca9bb2a8517a1b3b08bbeb1@git.kernel.org>
Date:   Fri, 3 Nov 2017 07:23:37 -0700
From:   tip-bot for Namhyung Kim <tipbot@...or.com>
To:     linux-tip-commits@...r.kernel.org
Cc:     peterz@...radead.org, namhyung@...nel.org,
        linux-kernel@...r.kernel.org, mingo@...nel.org, jolsa@...nel.org,
        milian.wolff@...b.com, yao.jin@...ux.intel.com, tglx@...utronix.de,
        acme@...hat.com, hpa@...or.com
Subject: [tip:perf/core] perf srcline: Fix memory leak in addr2inlines()

Commit-ID:  b7b75a60b291cc699ca9bb2a8517a1b3b08bbeb1
Gitweb:     https://git.kernel.org/tip/b7b75a60b291cc699ca9bb2a8517a1b3b08bbeb1
Author:     Namhyung Kim <namhyung@...nel.org>
AuthorDate: Tue, 31 Oct 2017 11:06:53 +0900
Committer:  Arnaldo Carvalho de Melo <acme@...hat.com>
CommitDate: Wed, 1 Nov 2017 11:43:56 -0300

perf srcline: Fix memory leak in addr2inlines()

When libbfd is not used, addr2inlines() executes `addr2line -i` and
process output line by line.  But it resets filename to NULL in the loop
so getline() allocates additional memory everytime instead of realloc.

Signed-off-by: Namhyung Kim <namhyung@...nel.org>
Acked-by: Jiri Olsa <jolsa@...nel.org>
Cc: Jin Yao <yao.jin@...ux.intel.com>
Cc: Milian Wolff <milian.wolff@...b.com>
Cc: Peter Zijlstra <peterz@...radead.org>
Cc: kernel-team@....com
Link: http://lkml.kernel.org/r/20171031020654.31163-1-namhyung@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@...hat.com>
---
 tools/perf/util/srcline.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/tools/perf/util/srcline.c b/tools/perf/util/srcline.c
index c143c3b..51dc49c 100644
--- a/tools/perf/util/srcline.c
+++ b/tools/perf/util/srcline.c
@@ -456,20 +456,17 @@ static struct inline_node *addr2inlines(const char *dso_name, u64 addr,
 	while (getline(&filename, &len, fp) != -1) {
 		char *srcline;
 
-		if (filename_split(filename, &line_nr) != 1) {
-			free(filename);
+		if (filename_split(filename, &line_nr) != 1)
 			goto out;
-		}
 
 		srcline = srcline_from_fileline(filename, line_nr);
 		if (inline_list__append(sym, srcline, node) != 0)
 			goto out;
-
-		filename = NULL;
 	}
 
 out:
 	pclose(fp);
+	free(filename);
 
 	return node;
 }

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ