[PATCH v3 0/3] perf tools: Fix memory issues
From: Michalis Niarchos via B4 Relay
Date: Mon Aug 03 2026 - 11:34:29 EST
Running:
$ perf kvm stat record -a sleep 10
gives this output:
[ perf record: Woken up 1 times to write data ]
[ perf record: Captured and wrote 1.361 MB perf.data.guest ]
double free or corruption (!prev)
In the process of resolving this, I came across some memory leaks.
Signed-off-by: Michalis Niarchos <michael.niarchos@xxxxxxxxx>
---
Changes in v3:
- Moved dead code removal to the correct patch.
- Squashed double free patches, as both fix the same rec_argv
double-free/leak pattern.
- Link to v2: https://patch.msgid.link/20260803-perf-kvm-fixes-v2-0-1b337189fffc@xxxxxxxxx
Changes in v2:
- Removed code block that was rendered dead by the
get_filename_for_perf_kvm() change.
- Dropped invalid free() fix from kvm_events_report().
- Added double free fixes for: __cmd_record(), __cmd_report(),
__cmd_buildid_list(), and __cmd_top(), which follow the same pattern
as kvm_events_record().
- Link to v1: https://patch.msgid.link/20260803-perf-kvm-fixes-v1-0-a5db849ac973@xxxxxxxxx
To: Peter Zijlstra <peterz@xxxxxxxxxxxxx>
To: Ingo Molnar <mingo@xxxxxxxxxx>
To: Arnaldo Carvalho de Melo <acme@xxxxxxxxxx>
To: Namhyung Kim <namhyung@xxxxxxxxxx>
To: Mark Rutland <mark.rutland@xxxxxxx>
To: Alexander Shishkin <alexander.shishkin@xxxxxxxxxxxxxxx>
To: Jiri Olsa <jolsa@xxxxxxxxxx>
To: Ian Rogers <irogers@xxxxxxxxxx>
To: Adrian Hunter <adrian.hunter@xxxxxxxxx>
To: James Clark <james.clark@xxxxxxxxxx>
Cc: linux-perf-users@xxxxxxxxxxxxxxx
Cc: linux-kernel@xxxxxxxxxxxxxxx
---
Michalis Niarchos (3):
perf tools: Fix memory leak in cmd_kvm()
perf tools: Fix double free and memory leak issues
perf tools: Fix memory leak in cmd_kvm()
tools/perf/builtin-kvm.c | 99 +++++++++++-------------
tools/perf/util/kvm-stat-arch/kvm-stat-powerpc.c | 4 +-
tools/perf/util/kvm-stat-arch/kvm-stat-x86.c | 10 +--
3 files changed, 50 insertions(+), 63 deletions(-)
---
base-commit: a1ed064cb4db70af8c4177b3805ca5b8b0be567e
change-id: 20260731-perf-kvm-fixes-a17f0aa048ad
Best regards,
--
Michalis Niarchos <michael.niarchos@xxxxxxxxx>