diff options
| author | Ian Rogers <irogers@google.com> | 2025-04-01 13:27:15 -0700 |
|---|---|---|
| committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2025-05-08 11:49:40 -0300 |
| commit | 8830091383b034981d882773078e18bb2a7e0e53 (patch) | |
| tree | 8b3e9fde0f223e5b0e6e9c06a770ee21f68bbf22 | |
| parent | Merge remote-tracking branch 'torvalds/master' into perf-tools-next (diff) | |
| download | linux-8830091383b034981d882773078e18bb2a7e0e53.tar.gz linux-8830091383b034981d882773078e18bb2a7e0e53.zip | |
perf trace: Free the files.max entry in files->table
The files.max is the maximum valid fd in the files array and so
freeing the values needs to be inclusive of the max value.
Reviewed-by: Howard Chu <howardchu95@gmail.com>
Signed-off-by: Ian Rogers <irogers@google.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Kan Liang <kan.liang@linux.intel.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: https://lore.kernel.org/r/20250401202715.3493567-1-irogers@google.com
[ split from a larger patch ]
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
| -rw-r--r-- | tools/perf/builtin-trace.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c index 809b4d5b0a8a..c39b7f8ff846 100644 --- a/tools/perf/builtin-trace.c +++ b/tools/perf/builtin-trace.c @@ -1653,7 +1653,7 @@ static const size_t trace__entry_str_size = 2048; static void thread_trace__free_files(struct thread_trace *ttrace) { - for (int i = 0; i < ttrace->files.max; ++i) { + for (int i = 0; i <= ttrace->files.max; ++i) { struct file *file = ttrace->files.table + i; zfree(&file->pathname); } @@ -1699,6 +1699,7 @@ static int trace__set_fd_pathname(struct thread *thread, int fd, const char *pat if (file != NULL) { struct stat st; + if (stat(pathname, &st) == 0) file->dev_maj = major(st.st_rdev); file->pathname = strdup(pathname); |
