Skip to content

Commit b8f7d86

Browse files
olsajiriacmel
authored andcommitted
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 <[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]> Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
1 parent befa09b commit b8f7d86

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

tools/perf/util/data.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ static int open_file(struct perf_data *data)
237237
open_file_read(data) : open_file_write(data);
238238

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

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

271271
void perf_data__close(struct perf_data *data)
272272
{
273-
free(data->file.path);
273+
zfree(&data->file.path);
274274
close(data->file.fd);
275275
}
276276

0 commit comments

Comments
 (0)