Skip to content

Commit dd0ec30

Browse files
committed
perf evsel: Ensure the fallback message is always written to
JIRA: https://issues.redhat.com/browse/RHEL-78200 upstream ======== commit 24937ee Author: Ian Rogers <irogers@google.com> Date: Thu Sep 18 10:24:15 2025 -0700 description =========== The fallback message is unconditionally printed in places like record__open(). If no fallback is attempted this can lead to printing uninitialized data, crashes, etc. Fixes: c0a5434 ("perf evsel: Introduce event fallback method") Signed-off-by: Ian Rogers <irogers@google.com> Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com> Cc: Howard Chu <howardchu95@gmail.com> Cc: Ingo Molnar <mingo@redhat.com> Cc: James Clark <james.clark@linaro.org> Cc: Jiri Olsa <jolsa@kernel.org> Cc: Kan Liang <kan.liang@linux.intel.com> Cc: Mark Rutland <mark.rutland@arm.com> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Peter Zijlstra <peterz@infradead.org> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com> Signed-off-by: Anubhav Shelat <ashelat@redhat.com>
1 parent e82b970 commit dd0ec30

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

tools/perf/util/evsel.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3562,15 +3562,15 @@ bool evsel__fallback(struct evsel *evsel, struct target *target, int err,
35623562

35633563
/* If event has exclude user then don't exclude kernel. */
35643564
if (evsel->core.attr.exclude_user)
3565-
return false;
3565+
goto no_fallback;
35663566

35673567
/* Is there already the separator in the name. */
35683568
if (strchr(name, '/') ||
35693569
(strchr(name, ':') && !evsel->is_libpfm_event))
35703570
sep = "";
35713571

35723572
if (asprintf(&new_name, "%s%su", name, sep) < 0)
3573-
return false;
3573+
goto no_fallback;
35743574

35753575
free(evsel->name);
35763576
evsel->name = new_name;
@@ -3593,17 +3593,19 @@ bool evsel__fallback(struct evsel *evsel, struct target *target, int err,
35933593
sep = "";
35943594

35953595
if (asprintf(&new_name, "%s%sH", name, sep) < 0)
3596-
return false;
3596+
goto no_fallback;
35973597

35983598
free(evsel->name);
35993599
evsel->name = new_name;
36003600
/* Apple M1 requires exclude_guest */
3601-
scnprintf(msg, msgsize, "trying to fall back to excluding guest samples");
3601+
scnprintf(msg, msgsize, "Trying to fall back to excluding guest samples");
36023602
evsel->core.attr.exclude_guest = 1;
36033603

36043604
return true;
36053605
}
3606-
3606+
no_fallback:
3607+
scnprintf(msg, msgsize, "No fallback found for '%s' for error %d",
3608+
evsel__name(evsel), err);
36073609
return false;
36083610
}
36093611

0 commit comments

Comments
 (0)