Skip to contentSkip to conversation

perf: dso_load - move name malloc to when needed

PATCH In review David Ahern 1 participant 2 messages Jan 14, 2013 – Jan 25, 2013 perf events

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 perf: dso_load - move name malloc to when needed

memory is currently leaked on some paths.

---
 tools/perf/util/symbol.c |    8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
tools/perf/util/symbol.c +4 -4
index 61edfd0..e9c0c3a 100644
@@ -775,10 +775,6 @@ int dso__load(struct dso *dso, struct map *map, symbol_filter_t filter)
 	else
 		machine = NULL;
 
-	name = malloc(PATH_MAX);
-	if (!name)
-		return -1;
-
 	dso->adjust_symbols = 0;
 
 	if (strncmp(dso->name, "/tmp/perf-", 10) == 0) {
@@ -802,6 +798,10 @@ int dso__load(struct dso *dso, struct map *map, symbol_filter_t filter)
 	if (machine)
 		root_dir = machine->root_dir;
 
+	name = malloc(PATH_MAX);
+	if (!name)
+		return -1;
+
 	/* Iterate over candidate debug images.
 	 * Keep track of "interesting" ones (those which have a symtab, dynsym,
 	 * and/or opd section) for processing.
Signature · 1 line
1.7.10.1
#1 lore raw

[tip:perf/core] perf symbols: Move name malloc to when needed in dso__load

Commit-ID:  164c800e42657e586f6fd446b3d8d41cf1f815f1
Gitweb:     http://git.kernel.org/tip/164c800e42657e586f6fd446b3d8d41cf1f815f1
Author:     David Ahern <[email protected]>
AuthorDate: Mon, 14 Jan 2013 10:46:47 -0700
Committer:  Arnaldo Carvalho de Melo <[email protected]>
CommitDate: Thu, 24 Jan 2013 16:40:30 -0300

perf symbols: Move name malloc to when needed in dso__load

Memory is currently leaked on some paths.

---
 tools/perf/util/symbol.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
tools/perf/util/symbol.c +4 -4
index 2960284..daf9554 100644
@@ -768,10 +768,6 @@ int dso__load(struct dso *dso, struct map *map, symbol_filter_t filter)
 	else
 		machine = NULL;
 
-	name = malloc(PATH_MAX);
-	if (!name)
-		return -1;
-
 	dso->adjust_symbols = 0;
 
 	if (strncmp(dso->name, "/tmp/perf-", 10) == 0) {
@@ -795,6 +791,10 @@ int dso__load(struct dso *dso, struct map *map, symbol_filter_t filter)
 	if (machine)
 		root_dir = machine->root_dir;
 
+	name = malloc(PATH_MAX);
+	if (!name)
+		return -1;
+
 	/* Iterate over candidate debug images.
 	 * Keep track of "interesting" ones (those which have a symtab, dynsym,
 	 * and/or opd section) for processing.