Skip to contentSkip to conversation

perf top: Delete maps on exit

tip:perf/core tip-bot for Arnaldo Carvalho de Melo 1 participant 1 message Feb 1, 2013 perf events

lore
Share & tools
lore
#0 lore raw
Commit-ID:  0de233b9c4f8c83b2cb655bfdbec306c8da81199
Gitweb:     http://git.kernel.org/tip/0de233b9c4f8c83b2cb655bfdbec306c8da81199
Author:     Arnaldo Carvalho de Melo <[email protected]>
AuthorDate: Wed, 30 Jan 2013 14:01:20 -0300
Committer:  Arnaldo Carvalho de Melo <[email protected]>
CommitDate: Thu, 31 Jan 2013 13:07:43 -0300

perf top: Delete maps on exit

Removing one more memory leak found with valgrind.

Cc David Ahern <[email protected]>
Cc Frederic Weisbecker <[email protected]>
Cc Jiri Olsa <[email protected]>
Cc Mike Galbraith <[email protected]>
Cc Namhyung Kim <[email protected]>
Cc Paul Mackerras <[email protected]>
Cc Peter Zijlstra <[email protected]>
Cc Stephane Eranian <[email protected]>
---
 tools/perf/builtin-top.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
tools/perf/builtin-top.c +4 -2
index 903e4f4..f561757 100644
@@ -1164,7 +1164,7 @@ int cmd_top(int argc, const char **argv, const char *prefix __maybe_unused)
 	if (!top.evlist->nr_entries &&
 	    perf_evlist__add_default(top.evlist) < 0) {
 		ui__error("Not enough memory for event selector list\n");
-		return -ENOMEM;
+		goto out_delete_maps;
 	}
 
 	symbol_conf.nr_events = top.evlist->nr_entries;
@@ -1187,7 +1187,7 @@ int cmd_top(int argc, const char **argv, const char *prefix __maybe_unused)
 	} else {
 		ui__error("frequency and count are zero, aborting\n");
 		status = -EINVAL;
-		goto out_delete_evlist;
+		goto out_delete_maps;
 	}
 
 	top.sym_evsel = perf_evlist__first(top.evlist);
@@ -1220,6 +1220,8 @@ int cmd_top(int argc, const char **argv, const char *prefix __maybe_unused)
 
 	status = __cmd_top(&top);
 
+out_delete_maps:
+	perf_evlist__delete_maps(top.evlist);
 out_delete_evlist:
 	perf_evlist__delete(top.evlist);