lkml.org 
[lkml]   [2019]   [Mar]   [5]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 7/8] perf tools: Fix double free in perf_data__close
Date
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.

Fixes: 2d4f27999b88 ("perf data: Add global path holder")
Link: http://lkml.kernel.org/n/tip-2g1zaoxmgmaxbuz8yvopq32v@git.kernel.org
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
tools/perf/util/session.c | 4 +---
1 file changed, 1 insertion(+), 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,

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

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

return session;

- out_close:
- perf_data__close(data);
out_delete:
perf_session__delete(session);
out:
--
2.17.2
\
 
 \ /
  Last update: 2019-03-05 16:27    [W:0.123 / U:1.228 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site