diff options
author | Jiri Olsa <jolsa@kernel.org> | 2019-03-05 10:25:35 -0500 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2019-03-06 16:20:33 -0500 |
commit | befa09b61f8bf1d7c34b8e6405f08d804640573c (patch) | |
tree | e3dfd454a14d78b5872db51afd31b87691b2d796 /tools | |
parent | 5b61adb16599be04346e7e943c1b5113b57485ad (diff) |
perf session: Fix double free in perf_data__close
We can't call perf_data__close and subsequently perf_session__delete,
because it will call perf_data__close again and cause double free for
data->file.path.
$ perf report -i .
incompatible file format (rerun with -v to learn more)
free(): double free detected in tcache 2
Aborted (core dumped)
In fact we don't need to call perf_data__close at all, because at the
time the got out_close is reached, session->data is already initialized,
so the perf_data__close call will be triggered from
perf_session__delete.
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Jonas Rabenstein <jonas.rabenstein@studium.uni-erlangen.de>
Cc: Nageswara R Sastry <nasastry@in.ibm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Ravi Bangoria <ravi.bangoria@linux.ibm.com>
Fixes: 2d4f27999b88 ("perf data: Add global path holder")
Link: http://lkml.kernel.org/r/20190305152536.21035-8-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/perf/util/session.c | 4 |
1 files changed, 1 insertions, 3 deletions
diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c index c764bbc91009..db643f3c2b95 100644 --- a/tools/perf/util/session.c +++ b/tools/perf/util/session.c | |||
@@ -140,7 +140,7 @@ struct perf_session *perf_session__new(struct perf_data *data, | |||
140 | 140 | ||
141 | if (perf_data__is_read(data)) { | 141 | if (perf_data__is_read(data)) { |
142 | if (perf_session__open(session) < 0) | 142 | if (perf_session__open(session) < 0) |
143 | goto out_close; | 143 | goto out_delete; |
144 | 144 | ||
145 | /* | 145 | /* |
146 | * set session attributes that are present in perf.data | 146 | * set session attributes that are present in perf.data |
@@ -181,8 +181,6 @@ struct perf_session *perf_session__new(struct perf_data *data, | |||
181 | 181 | ||
182 | return session; | 182 | return session; |
183 | 183 | ||
184 | out_close: | ||
185 | perf_data__close(data); | ||
186 | out_delete: | 184 | out_delete: |
187 | perf_session__delete(session); | 185 | perf_session__delete(session); |
188 | out: | 186 | out: |