]> git.proxmox.com Git - mirror_ubuntu-focal-kernel.git/commit
perf data: Fix double free in perf_session__delete()
authorAlexey Bayduraev <alexey.v.bayduraev@linux.intel.com>
Fri, 18 Feb 2022 15:23:41 +0000 (18:23 +0300)
committerStefan Bader <stefan.bader@canonical.com>
Fri, 20 May 2022 13:17:11 +0000 (15:17 +0200)
commit215be6d4c6b5c9869ce2337bf5bac445b116fe29
tree694e3eeb3c306db2e0b4933886f90033dee77daf
parentd83097b9ebf2e408db87d6eb921b719bd92355a9
perf data: Fix double free in perf_session__delete()

BugLink: https://bugs.launchpad.net/bugs/1969236
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: 145520631130bd64 ("perf data: Add perf_data__(create_dir|close_dir) functions")
Signed-off-by: Alexey Bayduraev <alexey.v.bayduraev@linux.intel.com>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexander Antonov <alexander.antonov@linux.intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Alexei Budankov <abudankov@huawei.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: https://lore.kernel.org/r/20220218152341.5197-2-alexey.v.bayduraev@linux.intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
tools/perf/util/data.c