aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/builtin-report.c
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2010-05-09 11:01:05 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2010-05-09 12:07:39 -0400
commit39d1e1b1e26dc84d40bf2792287d0d61e44b57df (patch)
tree18c5f4123a57f56501c350d2228354b295a50cb7 /tools/perf/builtin-report.c
parent139633c6a43781cd44798165b0472a34bf53a1e8 (diff)
perf report: Fix leak of resolved callchains array on error path
Cc: Frédéric Weisbecker <fweisbec@gmail.com> Cc: Mike Galbraith <efault@gmx.de> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Tom Zanussi <tzanussi@gmail.com> LKML-Reference: <new-submission> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/builtin-report.c')
-rw-r--r--tools/perf/builtin-report.c16
1 files changed, 7 insertions, 9 deletions
diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c
index 1cae8771379..3a70c5807c0 100644
--- a/tools/perf/builtin-report.c
+++ b/tools/perf/builtin-report.c
@@ -83,7 +83,7 @@ static int perf_session__add_hist_entry(struct perf_session *self,
83 struct map_symbol *syms = NULL; 83 struct map_symbol *syms = NULL;
84 struct symbol *parent = NULL; 84 struct symbol *parent = NULL;
85 bool hit; 85 bool hit;
86 int err; 86 int err = -ENOMEM;
87 struct hist_entry *he; 87 struct hist_entry *he;
88 struct event_stat_id *stats; 88 struct event_stat_id *stats;
89 struct perf_event_attr *attr; 89 struct perf_event_attr *attr;
@@ -101,26 +101,24 @@ static int perf_session__add_hist_entry(struct perf_session *self,
101 else 101 else
102 stats = get_stats(self, data->id, 0, 0); 102 stats = get_stats(self, data->id, 0, 0);
103 if (stats == NULL) 103 if (stats == NULL)
104 return -ENOMEM; 104 goto out_free_syms;
105 he = __perf_session__add_hist_entry(&stats->hists, al, parent, 105 he = __perf_session__add_hist_entry(&stats->hists, al, parent,
106 data->period, &hit); 106 data->period, &hit);
107 if (he == NULL) 107 if (he == NULL)
108 return -ENOMEM; 108 goto out_free_syms;
109 109
110 if (hit) 110 if (hit)
111 __perf_session__add_count(he, al, data->period); 111 __perf_session__add_count(he, al, data->period);
112 112
113 err = 0;
113 if (symbol_conf.use_callchain) { 114 if (symbol_conf.use_callchain) {
114 if (!hit) 115 if (!hit)
115 callchain_init(he->callchain); 116 callchain_init(he->callchain);
116 err = append_chain(he->callchain, data->callchain, syms); 117 err = append_chain(he->callchain, data->callchain, syms);
117 free(syms);
118
119 if (err)
120 return err;
121 } 118 }
122 119out_free_syms:
123 return 0; 120 free(syms);
121 return err;
124} 122}
125 123
126static int add_event_total(struct perf_session *session, 124static int add_event_total(struct perf_session *session,