Commit 82aac553 authored by Ian Rogers's avatar Ian Rogers Committed by Namhyung Kim
Browse files

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: 754baf42 ("perf pmu: Change aliases from list to hashmap")
Signed-off-by: default avatarIan Rogers <irogers@google.com>
Link: https://lore.kernel.org/r/20250717150855.1032526-2-irogers@google.com


Signed-off-by: default avatarNamhyung Kim <namhyung@kernel.org>
parent 478272d1
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -453,7 +453,7 @@ static struct perf_pmu_alias *perf_pmu__find_alias(struct perf_pmu *pmu,
{
	struct perf_pmu_alias *alias;
	bool has_sysfs_event;
	char event_file_name[FILENAME_MAX + 8];
	char event_file_name[NAME_MAX + 8];

	if (hashmap__find(pmu->aliases, name, &alias))
		return alias;
@@ -752,7 +752,7 @@ static int pmu_aliases_parse(struct perf_pmu *pmu)

static int pmu_aliases_parse_eager(struct perf_pmu *pmu, int sysfs_fd)
{
	char path[FILENAME_MAX + 7];
	char path[NAME_MAX + 8];
	int ret, events_dir_fd;

	scnprintf(path, sizeof(path), "%s/events", pmu->name);