perf kvm: Do not copy filename string

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.

Tested-by: Ian Rogers <irogers@google.com>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
This commit is contained in:
Namhyung Kim 2026-07-01 12:41:51 -07:00
parent cd589eba99
commit 5169bd7647

View File

@ -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;
}
@ -2148,15 +2148,9 @@ int cmd_kvm(int argc, const char **argv)
if (!perf_host)
perf_guest = 1;
if (!file_name) {
if (!file_name)
file_name = get_filename_for_perf_kvm();
if (!file_name) {
pr_err("Failed to allocate memory for filename\n");
return -ENOMEM;
}
}
if (strlen(argv[0]) > 2 && strstarts("record", argv[0]))
return __cmd_record(file_name, argc, argv);
else if (strlen(argv[0]) > 2 && strstarts("report", argv[0]))