diff options
author | Namhyung Kim <namhyung.kim@lge.com> | 2013-03-15 01:48:50 -0400 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2013-03-15 12:06:11 -0400 |
commit | 3beb0861438f63bc2025f8afba213dc3d0458bc5 (patch) | |
tree | f265a5133fd17157f474c5b2981501fd60dedb01 /tools/perf | |
parent | a74b4b66cc027110272a18cd50cc6ee93483e78d (diff) |
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: Namhyung 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.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf')
-rw-r--r-- | tools/perf/builtin-trace.c | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c index 49fedb51d569..ab3ed4af1466 100644 --- a/tools/perf/builtin-trace.c +++ b/tools/perf/builtin-trace.c | |||
@@ -452,7 +452,7 @@ static int trace__run(struct trace *trace, int argc, const char **argv) | |||
452 | err = trace__symbols_init(trace, evlist); | 452 | err = trace__symbols_init(trace, evlist); |
453 | if (err < 0) { | 453 | if (err < 0) { |
454 | printf("Problems initializing symbol libraries!\n"); | 454 | printf("Problems initializing symbol libraries!\n"); |
455 | goto out_delete_evlist; | 455 | goto out_delete_maps; |
456 | } | 456 | } |
457 | 457 | ||
458 | perf_evlist__config(evlist, &trace->opts); | 458 | perf_evlist__config(evlist, &trace->opts); |
@@ -465,20 +465,20 @@ static int trace__run(struct trace *trace, int argc, const char **argv) | |||
465 | argv, false, false); | 465 | argv, false, false); |
466 | if (err < 0) { | 466 | if (err < 0) { |
467 | printf("Couldn't run the workload!\n"); | 467 | printf("Couldn't run the workload!\n"); |
468 | goto out_delete_evlist; | 468 | goto out_delete_maps; |
469 | } | 469 | } |
470 | } | 470 | } |
471 | 471 | ||
472 | err = perf_evlist__open(evlist); | 472 | err = perf_evlist__open(evlist); |
473 | if (err < 0) { | 473 | if (err < 0) { |
474 | printf("Couldn't create the events: %s\n", strerror(errno)); | 474 | printf("Couldn't create the events: %s\n", strerror(errno)); |
475 | goto out_delete_evlist; | 475 | goto out_delete_maps; |
476 | } | 476 | } |
477 | 477 | ||
478 | err = perf_evlist__mmap(evlist, UINT_MAX, false); | 478 | err = perf_evlist__mmap(evlist, UINT_MAX, false); |
479 | if (err < 0) { | 479 | if (err < 0) { |
480 | printf("Couldn't mmap the events: %s\n", strerror(errno)); | 480 | printf("Couldn't mmap the events: %s\n", strerror(errno)); |
481 | goto out_delete_evlist; | 481 | goto out_close_evlist; |
482 | } | 482 | } |
483 | 483 | ||
484 | perf_evlist__enable(evlist); | 484 | perf_evlist__enable(evlist); |
@@ -534,7 +534,7 @@ again: | |||
534 | 534 | ||
535 | if (trace->nr_events == before) { | 535 | if (trace->nr_events == before) { |
536 | if (done) | 536 | if (done) |
537 | goto out_delete_evlist; | 537 | goto out_unmap_evlist; |
538 | 538 | ||
539 | poll(evlist->pollfd, evlist->nr_fds, -1); | 539 | poll(evlist->pollfd, evlist->nr_fds, -1); |
540 | } | 540 | } |
@@ -544,6 +544,12 @@ again: | |||
544 | 544 | ||
545 | goto again; | 545 | goto again; |
546 | 546 | ||
547 | out_unmap_evlist: | ||
548 | perf_evlist__munmap(evlist); | ||
549 | out_close_evlist: | ||
550 | perf_evlist__close(evlist); | ||
551 | out_delete_maps: | ||
552 | perf_evlist__delete_maps(evlist); | ||
547 | out_delete_evlist: | 553 | out_delete_evlist: |
548 | perf_evlist__delete(evlist); | 554 | perf_evlist__delete(evlist); |
549 | out: | 555 | out: |