From 3c6e8a37eff15c3f834ba80c201932712e4b71d4 Mon Sep 17 00:00:00 2001 From: Weimin Xiong Date: Thu, 16 Jul 2026 10:51:03 +0800 Subject: [PATCH] unix: Use kvmalloc_array() for BPF iterator batches Use kvmalloc_array() instead of open-coding the element-size multiplication when allocating the Unix-domain BPF iterator batch. Signed-off-by: Weimin Xiong Signed-off-by: Andrii Nakryiko --- net/unix/af_unix.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c index f7a9d55eee8a..6664ead46216 100644 --- a/net/unix/af_unix.c +++ b/net/unix/af_unix.c @@ -3659,8 +3659,8 @@ static int bpf_iter_unix_realloc_batch(struct bpf_unix_iter_state *iter, { struct sock **new_batch; - new_batch = kvmalloc(sizeof(*new_batch) * new_batch_sz, - GFP_USER | __GFP_NOWARN); + new_batch = kvmalloc_array(new_batch_sz, sizeof(*new_batch), + GFP_USER | __GFP_NOWARN); if (!new_batch) return -ENOMEM;