Commit 5c3627b6 authored by Thorsten Blum's avatar Thorsten Blum Committed by Ingo Molnar
Browse files

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: default avatarThorsten Blum <thorsten.blum@linux.dev>
Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: https://lore.kernel.org/r/20250413104108.49142-2-thorsten.blum@linux.dev
parent 1734d98f
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -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;