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

perf tests: Fix Tool PMU test segfault

tool_pmu__event_to_str() now handles skipped events by returning NULL,
so it's wrong to re-check for a skip on the resulting string. Calling
tool_pmu__skip_event() with a NULL string results in a segfault so
remove the unnecessary skip to fix it:

$ perf test -vv "parsing with PMU name"

12.2: Parsing with PMU name:
...
---- unexpected signal (11) ----
12.2: Parsing with PMU name : FAILED!

Fixes: ee8aef2d2321 ("perf tools: Add skip check in tool_pmu__event_to_str()")
Signed-off-by: James Clark <james.clark@linaro.org>
Reported-by: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
Acked-by: Kan Liang <kan.liang@linux.intel.com>
Tested-by: Ian Rogers <irogers@google.com>
Link: https://lore.kernel.org/r/20250212163859.1489916-1-james.clark@linaro.org
Signed-off-by: Namhyung Kim <namhyung@kernel.org>

authored by

James Clark and committed by
Namhyung Kim
615ec00b ee8aef2d

+2 -2
+2 -2
tools/perf/tests/tool_pmu.c
··· 27 27 parse_events_error__init(&err); 28 28 ret = parse_events(evlist, str, &err); 29 29 if (ret) { 30 - if (tool_pmu__skip_event(tool_pmu__event_to_str(ev))) { 30 + if (!tool_pmu__event_to_str(ev)) { 31 31 ret = TEST_OK; 32 32 goto out; 33 33 } ··· 59 59 } 60 60 } 61 61 62 - if (!found && !tool_pmu__skip_event(tool_pmu__event_to_str(ev))) { 62 + if (!found && tool_pmu__event_to_str(ev)) { 63 63 pr_debug("FAILED %s:%d Didn't find tool event '%s' in parsed evsels\n", 64 64 __FILE__, __LINE__, str); 65 65 ret = TEST_FAIL;