[PATCH v2 4/6] perf kvm: Do not copy filename string

From: Namhyung Kim

Date: Tue Jun 23 2026 - 15:16:50 EST


As it removed STRDUP_FAIL_EXIT(), it no longer calls free() for elements
in the copied argv. Thus, the filename should not be allocated as well.
In fact, it's a pointer to string literals and should be fine to pass
the pointer.

Signed-off-by: Namhyung Kim <namhyung@xxxxxxxxxx>
---
tools/perf/builtin-kvm.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/tools/perf/builtin-kvm.c b/tools/perf/builtin-kvm.c
index eaf9297cc34d32c1..4200bf899b51c2a9 100644
--- a/tools/perf/builtin-kvm.c
+++ b/tools/perf/builtin-kvm.c
@@ -607,11 +607,11 @@ static const char *get_filename_for_perf_kvm(void)
const char *filename;

if (perf_host && !perf_guest)
- filename = strdup("perf.data.host");
+ filename = "perf.data.host";
else if (!perf_host && perf_guest)
- filename = strdup("perf.data.guest");
+ filename = "perf.data.guest";
else
- filename = strdup("perf.data.kvm");
+ filename = "perf.data.kvm";

return filename;
}
--
2.55.0.rc0.799.gd6f94ed593-goog