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

perf pmu: Switch FILENAME_MAX to NAME_MAX

FILENAME_MAX is the same as PATH_MAX (4kb) in glibc rather than
NAME_MAX's 255. Switch to using NAME_MAX and ensure the '\0' is
accounted for in the path's buffer size.

Fixes: 754baf426e09 ("perf pmu: Change aliases from list to hashmap")
Signed-off-by: Ian Rogers <irogers@google.com>
Link: https://lore.kernel.org/r/20250717150855.1032526-2-irogers@google.com
Signed-off-by: Namhyung Kim <namhyung@kernel.org>

authored by

Ian Rogers and committed by
Namhyung Kim
82aac553 478272d1

+2 -2
+2 -2
tools/perf/util/pmu.c
··· 453 453 { 454 454 struct perf_pmu_alias *alias; 455 455 bool has_sysfs_event; 456 - char event_file_name[FILENAME_MAX + 8]; 456 + char event_file_name[NAME_MAX + 8]; 457 457 458 458 if (hashmap__find(pmu->aliases, name, &alias)) 459 459 return alias; ··· 752 752 753 753 static int pmu_aliases_parse_eager(struct perf_pmu *pmu, int sysfs_fd) 754 754 { 755 - char path[FILENAME_MAX + 7]; 755 + char path[NAME_MAX + 8]; 756 756 int ret, events_dir_fd; 757 757 758 758 scnprintf(path, sizeof(path), "%s/events", pmu->name);