From: Ian Rogers Date: Tue, 27 May 2025 21:50:35 +0000 (-0700) Subject: perf pmu: Avoid segv for missing name/alias_name in wildcarding X-Git-Tag: v6.16-rc1~57^2~16 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=2a2a7f5e7deffa363b438308812989ded126a48a;p=thirdparty%2Flinux.git perf pmu: Avoid segv for missing name/alias_name in wildcarding The pmu name or alias_name fields may be NULL and should be skipped if so. This is done in all loops of perf_pmu___name_match except the final wildcard loop which was an oversight. Fixes: 63e287131cf0c59b ("perf pmu: Rename name matching for no suffix or wildcard variants") Signed-off-by: Ian Rogers Acked-by: Namhyung Kim Cc: Adrian Hunter Cc: Alexander Shishkin Cc: Ingo Molnar Cc: James Clark Cc: Jiri Olsa Cc: Kan Liang Cc: Mark Rutland Cc: Peter Zijlstra Link: https://lore.kernel.org/r/20250527215035.187992-1-irogers@google.com [ Fixup the Fixes: tag to the right commit ] Signed-off-by: Arnaldo Carvalho de Melo --- diff --git a/tools/perf/util/pmu.c b/tools/perf/util/pmu.c index bc1178234d3b1..609828513f6cf 100644 --- a/tools/perf/util/pmu.c +++ b/tools/perf/util/pmu.c @@ -2143,6 +2143,9 @@ static bool perf_pmu___name_match(const struct perf_pmu *pmu, const char *to_mat for (size_t i = 0; i < ARRAY_SIZE(names); i++) { const char *name = names[i]; + if (!name) + continue; + if (wildcard && perf_pmu__match_wildcard_uncore(name, to_match)) return true; if (!wildcard && perf_pmu__match_ignoring_suffix_uncore(name, to_match))