[PATCH 2/4] perf tools: Fix memory leak in kvm_events_report()
From: Michalis Niarchos via B4 Relay
Date: Mon Aug 03 2026 - 06:50:38 EST
From: Michalis Niarchos <michael.niarchos@xxxxxxxxx>
parse_options() calls parse_options_subcommand(), which allocates the
usage string. Free it.
Signed-off-by: Michalis Niarchos <michael.niarchos@xxxxxxxxx>
---
tools/perf/builtin-kvm.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/tools/perf/builtin-kvm.c b/tools/perf/builtin-kvm.c
index 44c6998f2ee5..1a013698cae3 100644
--- a/tools/perf/builtin-kvm.c
+++ b/tools/perf/builtin-kvm.c
@@ -1755,6 +1755,9 @@ kvm_events_report(struct perf_kvm_stat *kvm, int argc, const char **argv)
if (argc)
usage_with_options(kvm_events_report_usage,
kvm_events_report_options);
+
+ /* free usage string allocated by parse_options */
+ free((void *)kvm_events_report_usage[0]);
}
#ifndef HAVE_SLANG_SUPPORT
--
2.55.0