Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

perf list: Fix memory leaks in print_tracepoint_events()

It should free entries (not only the array) filled by scandirat()
after use.

Reviewed-by: Ian Rogers <irogers@google.com>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: https://lore.kernel.org/r/20230427230502.1526136-1-namhyung@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by

Namhyung Kim and committed by
Arnaldo Carvalho de Melo
7586d11d b9f82b5c

+8 -4
+8 -4
tools/perf/util/print-events.c
··· 83 83 if (sys_dirent->d_type != DT_DIR || 84 84 !strcmp(sys_dirent->d_name, ".") || 85 85 !strcmp(sys_dirent->d_name, "..")) 86 - continue; 86 + goto next_sys; 87 87 88 88 dir_fd = openat(events_fd, sys_dirent->d_name, O_PATH); 89 89 if (dir_fd < 0) 90 - continue; 90 + goto next_sys; 91 91 92 92 evt_items = scandirat(events_fd, sys_dirent->d_name, &evt_namelist, NULL, alphasort); 93 93 for (int j = 0; j < evt_items; j++) { ··· 98 98 if (evt_dirent->d_type != DT_DIR || 99 99 !strcmp(evt_dirent->d_name, ".") || 100 100 !strcmp(evt_dirent->d_name, "..")) 101 - continue; 101 + goto next_evt; 102 102 103 103 snprintf(evt_path, sizeof(evt_path), "%s/id", evt_dirent->d_name); 104 104 evt_fd = openat(dir_fd, evt_path, O_RDONLY); 105 105 if (evt_fd < 0) 106 - continue; 106 + goto next_evt; 107 107 close(evt_fd); 108 108 109 109 snprintf(evt_path, MAXPATHLEN, "%s:%s", ··· 119 119 /*desc=*/NULL, 120 120 /*long_desc=*/NULL, 121 121 /*encoding_desc=*/NULL); 122 + next_evt: 123 + free(evt_namelist[j]); 122 124 } 123 125 close(dir_fd); 124 126 free(evt_namelist); 127 + next_sys: 128 + free(sys_namelist[i]); 125 129 } 126 130 127 131 free(sys_namelist);