mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-09-18 23:09:29 +02:00
perf stat: Fix evsel_list leak in cmd_stat
Fix a memory leak in cmd_stat() where evsel_list is leaked if an error
occurs while opening the output file.
Assisted-by: Antigravity:gemini-3.1-pro
Fixes: 361c99a661 ("perf evsel: Introduce perf_evlist")
Signed-off-by: Ian Rogers <irogers@google.com>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
This commit is contained in:
@@ -2735,7 +2735,8 @@ int cmd_stat(int argc, const char **argv)
|
||||
output = fopen(output_name, mode);
|
||||
if (!output) {
|
||||
perror("failed to create output file");
|
||||
return -1;
|
||||
status = -1;
|
||||
goto out;
|
||||
}
|
||||
if (!stat_config.json_output) {
|
||||
clock_gettime(CLOCK_REALTIME, &tm);
|
||||
@@ -2746,7 +2747,8 @@ int cmd_stat(int argc, const char **argv)
|
||||
output = fdopen(output_fd, mode);
|
||||
if (!output) {
|
||||
perror("Failed opening logfd");
|
||||
return -errno;
|
||||
status = -errno;
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2755,7 +2757,8 @@ int cmd_stat(int argc, const char **argv)
|
||||
parse_options_usage(stat_usage, stat_options, "o", 1);
|
||||
parse_options_usage(NULL, stat_options, "log-fd", 0);
|
||||
parse_options_usage(NULL, stat_options, "interval-clear", 0);
|
||||
return -1;
|
||||
status = -1;
|
||||
goto out;
|
||||
}
|
||||
|
||||
stat_config.output = output;
|
||||
|
||||
Reference in New Issue
Block a user