[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20241213210425.526512-6-irogers@google.com>
Date: Fri, 13 Dec 2024 13:04:22 -0800
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>, "Mike Rapoport (IBM)" <rppt@...nel.org>,
Wei Yang <richard.weiyang@...il.com>, James Clark <james.clark@...aro.org>,
Howard Chu <howardchu95@...il.com>, Kajol Jain <kjain@...ux.ibm.com>,
Athira Rajeev <atrajeev@...ux.vnet.ibm.com>, Ze Gao <zegao2021@...il.com>,
Weilin Wang <weilin.wang@...el.com>, linux-kernel@...r.kernel.org,
linux-perf-users@...r.kernel.org
Subject: [PATCH v1 5/8] tools headers: Add non-NULL assert to container_of
container_of on a NULL may yield a non-NULL, confusion and errors.
Signed-off-by: Ian Rogers <irogers@...gle.com>
---
tools/include/linux/kernel.h | 1 +
1 file changed, 1 insertion(+)
diff --git a/tools/include/linux/kernel.h b/tools/include/linux/kernel.h
index 10f74f021d55..8d617467c5c5 100644
--- a/tools/include/linux/kernel.h
+++ b/tools/include/linux/kernel.h
@@ -38,6 +38,7 @@
static_assert(__same_type(*(ptr), ((type *)0)->member) || \
__same_type(*(ptr), void), \
"pointer type mismatch in container_of()"); \
+ assert(ptr != NULL); \
((type *)(__mptr - offsetof(type, member))); })
#endif
--
2.47.1.613.gc27f4b7a9f-goog
Powered by blists - more mailing lists