Commit 3beb0861 authored by Namhyung Kim's avatar Namhyung Kim Committed by Arnaldo Carvalho de Melo

perf trace: Free evlist resources properly on return path

The trace_run() function calls several evlist functions but misses some
pair-wise cleanup routines on return path.  Fix it.
Signed-off-by: default avatarNamhyung Kim <namhyung@kernel.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1363326533-3310-3-git-send-email-namhyung@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent a74b4b66
...@@ -452,7 +452,7 @@ static int trace__run(struct trace *trace, int argc, const char **argv) ...@@ -452,7 +452,7 @@ static int trace__run(struct trace *trace, int argc, const char **argv)
err = trace__symbols_init(trace, evlist); err = trace__symbols_init(trace, evlist);
if (err < 0) { if (err < 0) {
printf("Problems initializing symbol libraries!\n"); printf("Problems initializing symbol libraries!\n");
goto out_delete_evlist; goto out_delete_maps;
} }
perf_evlist__config(evlist, &trace->opts); perf_evlist__config(evlist, &trace->opts);
...@@ -465,20 +465,20 @@ static int trace__run(struct trace *trace, int argc, const char **argv) ...@@ -465,20 +465,20 @@ static int trace__run(struct trace *trace, int argc, const char **argv)
argv, false, false); argv, false, false);
if (err < 0) { if (err < 0) {
printf("Couldn't run the workload!\n"); printf("Couldn't run the workload!\n");
goto out_delete_evlist; goto out_delete_maps;
} }
} }
err = perf_evlist__open(evlist); err = perf_evlist__open(evlist);
if (err < 0) { if (err < 0) {
printf("Couldn't create the events: %s\n", strerror(errno)); printf("Couldn't create the events: %s\n", strerror(errno));
goto out_delete_evlist; goto out_delete_maps;
} }
err = perf_evlist__mmap(evlist, UINT_MAX, false); err = perf_evlist__mmap(evlist, UINT_MAX, false);
if (err < 0) { if (err < 0) {
printf("Couldn't mmap the events: %s\n", strerror(errno)); printf("Couldn't mmap the events: %s\n", strerror(errno));
goto out_delete_evlist; goto out_close_evlist;
} }
perf_evlist__enable(evlist); perf_evlist__enable(evlist);
...@@ -534,7 +534,7 @@ static int trace__run(struct trace *trace, int argc, const char **argv) ...@@ -534,7 +534,7 @@ static int trace__run(struct trace *trace, int argc, const char **argv)
if (trace->nr_events == before) { if (trace->nr_events == before) {
if (done) if (done)
goto out_delete_evlist; goto out_unmap_evlist;
poll(evlist->pollfd, evlist->nr_fds, -1); poll(evlist->pollfd, evlist->nr_fds, -1);
} }
...@@ -544,6 +544,12 @@ static int trace__run(struct trace *trace, int argc, const char **argv) ...@@ -544,6 +544,12 @@ static int trace__run(struct trace *trace, int argc, const char **argv)
goto again; goto again;
out_unmap_evlist:
perf_evlist__munmap(evlist);
out_close_evlist:
perf_evlist__close(evlist);
out_delete_maps:
perf_evlist__delete_maps(evlist);
out_delete_evlist: out_delete_evlist:
perf_evlist__delete(evlist); perf_evlist__delete(evlist);
out: out:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment