From: Arnaldo Carvalho de Melo
mainline inclusion
from mainline-5.13-rc3
commit 3b2f17ad1770e51b8b4e68b5069c4f1ee477eff8
category: bugfix
issue: #I3ZXZF
CVE: NA
Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?i...
---------------------------
To avoid a NULL pointer dereference when the kernel supports the new
feature but the tooling still hasn't an entry for it.
This happened with the recently added PERF_COUNT_SW_CGROUP_SWITCHES
software event.
Reported-by: Thomas Richter
Cc: Adrian Hunter
Cc: Heiko Carstens
Cc: Jiri Olsa
Cc: Namhyung Kim
Cc: Sumanth Korikkar
Link: https://lore.kernel.org/linux-perf-users/YKVESEKRjKtILhog@kernel.org/
Signed-off-by: Arnaldo Carvalho de Melo
Signed-off-by: Yang Jihong
Reviewed-by: Kuohai Xu
Signed-off-by: Chen Jun
Signed-off-by: Yu Changchun
---
tools/perf/util/parse-events.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c
index 3b273580fb84..61bbbbeb9d3d 100644
--- a/tools/perf/util/parse-events.c
+++ b/tools/perf/util/parse-events.c
@@ -2810,9 +2810,14 @@ void print_symbol_events(const char *event_glob, unsigned type,
}
for (i = 0; i < max; i++, syms++) {
+ /*
+ * New attr.config still not supported here, the latest
+ * example was PERF_COUNT_SW_CGROUP_SWITCHES
+ */
+ if (syms->symbol == NULL)
+ continue;
- if (event_glob != NULL && syms->symbol != NULL &&
- !(strglobmatch(syms->symbol, event_glob) ||
+ if (event_glob != NULL && !(strglobmatch(syms->symbol, event_glob) ||
(syms->alias && strglobmatch(syms->alias, event_glob))))
continue;
--
2.22.0