Skip to contentSkip to conversation

unix: use kvmalloc_array() for BPF iterator batches

PATCH Applied Weimin Xiong 2 participants 2 messages Jul 16 – Jul 27

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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.

---

net/unix/af_unix.c +2 -2
index f7a9d55ee..6664ead46 100644
@@ -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;
 
#1 lore raw
This patch was applied to bpf/bpf-next.git (master) by Andrii Nakryiko <[email protected]>:

Hello:

This patch was applied to bpf/bpf-next.git (master) by Andrii Nakryiko <[email protected]>:

Quoted 5 lines · On Thu, 16 Jul 2026 10:51:03 +0800 you wrote:

Use kvmalloc_array() instead of open-coding the element-size multiplication when allocating the Unix-domain BPF iterator batch.

---

Here is the summary with links:
- unix: use kvmalloc_array() for BPF iterator batches

    https://git.kernel.org/bpf/bpf-next/c/3c6e8a37eff1

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html