mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-11-30 15:53:22 -05:00
perf data: Fix double free in perf_session__delete()
commit 69560e366fc4d5fca7bebb0e44edbfafc8bcaf05 upstream.
When perf_data__create_dir() fails, it calls close_dir(), but
perf_session__delete() also calls close_dir() and since dir.version and
dir.nr were initialized by perf_data__create_dir(), a double free occurs.
This patch moves the initialization of dir.version and dir.nr after
successful initialization of dir.files, that prevents double freeing.
This behavior is already implemented in perf_data__open_dir().
Fixes: 1455206311 ("perf data: Add perf_data__(create_dir|close_dir) functions")
Signed-off-by: Alexey Bayduraev <[email protected]>
Acked-by: Jiri Olsa <[email protected]>
Cc: Adrian Hunter <[email protected]>
Cc: Alexander Antonov <[email protected]>
Cc: Alexander Shishkin <[email protected]>
Cc: Alexei Budankov <[email protected]>
Cc: Andi Kleen <[email protected]>
Cc: Ingo Molnar <[email protected]>
Cc: Namhyung Kim <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
This commit is contained in:
parent
3174b09fe1
commit
dffce58f6f
1 changed files with 3 additions and 4 deletions
|
|
@ -44,10 +44,6 @@ int perf_data__create_dir(struct perf_data *data, int nr)
|
|||
if (!files)
|
||||
return -ENOMEM;
|
||||
|
||||
data->dir.version = PERF_DIR_VERSION;
|
||||
data->dir.files = files;
|
||||
data->dir.nr = nr;
|
||||
|
||||
for (i = 0; i < nr; i++) {
|
||||
struct perf_data_file *file = &files[i];
|
||||
|
||||
|
|
@ -62,6 +58,9 @@ int perf_data__create_dir(struct perf_data *data, int nr)
|
|||
file->fd = ret;
|
||||
}
|
||||
|
||||
data->dir.version = PERF_DIR_VERSION;
|
||||
data->dir.files = files;
|
||||
data->dir.nr = nr;
|
||||
return 0;
|
||||
|
||||
out_err:
|
||||
|
|
|
|||
Loading…
Reference in a new issue