Skip to content

Commit befa09b

Browse files
olsajiriacmel
authored andcommitted
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 <[email protected]> Cc: Alexander Shishkin <[email protected]> Cc: Andi Kleen <[email protected]> Cc: Jonas Rabenstein <[email protected]> Cc: Nageswara R Sastry <[email protected]> Cc: Namhyung Kim <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Ravi Bangoria <[email protected]> Fixes: 2d4f279 ("perf data: Add global path holder") Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
1 parent 5b61adb commit befa09b

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

tools/perf/util/session.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ struct perf_session *perf_session__new(struct perf_data *data,
140140

141141
if (perf_data__is_read(data)) {
142142
if (perf_session__open(session) < 0)
143-
goto out_close;
143+
goto out_delete;
144144

145145
/*
146146
* set session attributes that are present in perf.data
@@ -181,8 +181,6 @@ struct perf_session *perf_session__new(struct perf_data *data,
181181

182182
return session;
183183

184-
out_close:
185-
perf_data__close(data);
186184
out_delete:
187185
perf_session__delete(session);
188186
out:

0 commit comments

Comments
 (0)