[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250821163820.1132977-4-irogers@google.com>
Date: Thu, 21 Aug 2025 09:38:17 -0700
From: Ian Rogers <irogers@...gle.com>
To: Peter Zijlstra <peterz@...radead.org>, Ingo Molnar <mingo@...hat.com>,
Arnaldo Carvalho de Melo <acme@...nel.org>, Namhyung Kim <namhyung@...nel.org>,
Mark Rutland <mark.rutland@....com>,
Alexander Shishkin <alexander.shishkin@...ux.intel.com>, Jiri Olsa <jolsa@...nel.org>,
Ian Rogers <irogers@...gle.com>, Adrian Hunter <adrian.hunter@...el.com>,
Kan Liang <kan.liang@...ux.intel.com>, Chun-Tse Shao <ctshao@...gle.com>,
Blake Jones <blakejones@...gle.com>, James Clark <james.clark@...aro.org>,
Jan Polensky <japo@...ux.ibm.com>, Collin Funk <collin.funk1@...il.com>,
Howard Chu <howardchu95@...il.com>, Thomas Gleixner <tglx@...utronix.de>,
Nam Cao <namcao@...utronix.de>, Li Huafei <lihuafei1@...wei.com>,
"Steinar H. Gunderson" <sesse@...gle.com>, Athira Rajeev <atrajeev@...ux.ibm.com>,
linux-perf-users@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: [PATCH v2 3/5] perf evsel: Avoid container_of on a NULL leader
An evsel should typically have a leader of itself, however, in tests
like 'Sample parsing' a NULL leader may occur and the container_of
will return a corrupt pointer. Avoid this with an explicit NULL test.
Signed-off-by: Ian Rogers <irogers@...gle.com>
Fixes: fba7c86601e2 ("libperf: Move 'leader' from tools/perf to perf_evsel::leader")
Acked-by: Namhyung Kim <namhyung@...nel.org>
---
tools/perf/util/evsel.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
index d264c143b592..496f42434327 100644
--- a/tools/perf/util/evsel.c
+++ b/tools/perf/util/evsel.c
@@ -3935,6 +3935,8 @@ bool evsel__is_hybrid(const struct evsel *evsel)
struct evsel *evsel__leader(const struct evsel *evsel)
{
+ if (evsel->core.leader == NULL)
+ return NULL;
return container_of(evsel->core.leader, struct evsel, core);
}
--
2.51.0.rc1.193.gad69d77794-goog
Powered by blists - more mailing lists