summaryrefslogtreecommitdiffstats
path: root/tools/perf/builtin-stat.c
diff options
context:
space:
mode:
Diffstat (limited to 'tools/perf/builtin-stat.c')
-rw-r--r--tools/perf/builtin-stat.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c
index b55a534b4de0..352cf39d7c2f 100644
--- a/tools/perf/builtin-stat.c
+++ b/tools/perf/builtin-stat.c
@@ -607,7 +607,13 @@ try_again:
607 * group leaders. 607 * group leaders.
608 */ 608 */
609 read_counters(&(struct timespec) { .tv_nsec = t1-t0 }); 609 read_counters(&(struct timespec) { .tv_nsec = t1-t0 });
610 perf_evlist__close(evsel_list); 610
611 /*
612 * We need to keep evsel_list alive, because it's processed
613 * later the evsel_list will be closed after.
614 */
615 if (!STAT_RECORD)
616 perf_evlist__close(evsel_list);
611 617
612 return WEXITSTATUS(status); 618 return WEXITSTATUS(status);
613} 619}
@@ -1997,6 +2003,7 @@ int cmd_stat(int argc, const char **argv)
1997 perf_session__write_header(perf_stat.session, evsel_list, fd, true); 2003 perf_session__write_header(perf_stat.session, evsel_list, fd, true);
1998 } 2004 }
1999 2005
2006 perf_evlist__close(evsel_list);
2000 perf_session__delete(perf_stat.session); 2007 perf_session__delete(perf_stat.session);
2001 } 2008 }
2002 2009