[tip:perf/urgent] perf data: Force perf_data__open|close zero data->file.path

From: tip-bot for Jiri Olsa
Date: Sat Mar 09 2019 - 15:10:12 EST


Commit-ID: b8f7d86b5849ea7bb84bddc0345a3799049764d4
Gitweb: https://git.kernel.org/tip/b8f7d86b5849ea7bb84bddc0345a3799049764d4
Author: Jiri Olsa <jolsa@xxxxxxxxxx>
AuthorDate: Tue, 5 Mar 2019 16:25:36 +0100
Committer: Arnaldo Carvalho de Melo <acme@xxxxxxxxxx>
CommitDate: Wed, 6 Mar 2019 18:21:00 -0300

perf data: Force perf_data__open|close zero data->file.path

Making sure the data->file.path is zeroed on perf_data__open error path
and in perf_data__close, so we don't double free it in case someone call
it twice.

Signed-off-by: Jiri Olsa <jolsa@xxxxxxxxxx>
Cc: Alexander Shishkin <alexander.shishkin@xxxxxxxxxxxxxxx>
Cc: Andi Kleen <ak@xxxxxxxxxxxxxxx>
Cc: Jonas Rabenstein <jonas.rabenstein@xxxxxxxxxxxxxxxxxxxxxxx>
Cc: Nageswara R Sastry <nasastry@xxxxxxxxxx>
Cc: Namhyung Kim <namhyung@xxxxxxxxxx>
Cc: Peter Zijlstra <peterz@xxxxxxxxxxxxx>
Cc: Ravi Bangoria <ravi.bangoria@xxxxxxxxxxxxx>
Link: http://lkml.kernel.org/r/20190305152536.21035-9-jolsa@xxxxxxxxxx
Signed-off-by: Arnaldo Carvalho de Melo <acme@xxxxxxxxxx>
---
tools/perf/util/data.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tools/perf/util/data.c b/tools/perf/util/data.c
index 7bd5ddeb7a41..e098e189f93e 100644
--- a/tools/perf/util/data.c
+++ b/tools/perf/util/data.c
@@ -237,7 +237,7 @@ static int open_file(struct perf_data *data)
open_file_read(data) : open_file_write(data);

if (fd < 0) {
- free(data->file.path);
+ zfree(&data->file.path);
return -1;
}

@@ -270,7 +270,7 @@ int perf_data__open(struct perf_data *data)

void perf_data__close(struct perf_data *data)
{
- free(data->file.path);
+ zfree(&data->file.path);
close(data->file.fd);
}