aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorThorsten Blum <thorsten.blum@linux.dev>2025-04-13 12:41:09 +0200
committerIngo Molnar <mingo@kernel.org>2025-04-13 21:05:50 +0200
commit5c3627b6f0595f1ec27e6f5df903bd072e9b9136 (patch)
treeb6077062e310ba46150e5aee35f2895fd7c4d7f9
parentperf/arch: Record sample last_period before updating on the x86 and PowerPC platforms (diff)
downloadwireguard-linux-5c3627b6f0595f1ec27e6f5df903bd072e9b9136.tar.xz
wireguard-linux-5c3627b6f0595f1ec27e6f5df903bd072e9b9136.zip
perf/x86/intel/bts: Replace offsetof() with struct_size()
Use struct_size() to calculate the number of bytes to allocate for a new bts_buffer. Compared to offsetof(), struct_size() provides additional compile-time checks (e.g., __must_be_array()). Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev> Signed-off-by: Ingo Molnar <mingo@kernel.org> Cc: Peter Zijlstra <peterz@infradead.org> Link: https://lore.kernel.org/r/20250413104108.49142-2-thorsten.blum@linux.dev
-rw-r--r--arch/x86/events/intel/bts.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/arch/x86/events/intel/bts.c b/arch/x86/events/intel/bts.c
index da03f53bfa18..16bc89c8023b 100644
--- a/arch/x86/events/intel/bts.c
+++ b/arch/x86/events/intel/bts.c
@@ -101,7 +101,7 @@ bts_buffer_setup_aux(struct perf_event *event, void **pages,
if (overwrite && nr_buf > 1)
return NULL;
- bb = kzalloc_node(offsetof(struct bts_buffer, buf[nr_buf]), GFP_KERNEL, node);
+ bb = kzalloc_node(struct_size(bb, buf, nr_buf), GFP_KERNEL, node);
if (!bb)
return NULL;