Netdev List
 help / color / mirror / Atom feed
* [PATCH] tcp: use kvmalloc_array() for BPF iterator batches
@ 2026-07-16  2:51 Weimin Xiong
  2026-07-27 22:40 ` patchwork-bot+netdevbpf
  0 siblings, 1 reply; 2+ messages in thread
From: Weimin Xiong @ 2026-07-16  2:51 UTC (permalink / raw)
  To: Eric Dumazet, Neal Cardwell, Kuniyuki Iwashima
  Cc: netdev, linux-kernel, David S . Miller, Jakub Kicinski,
	Paolo Abeni, Simon Horman, Weimin Xiong

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

Signed-off-by: Weimin Xiong <xiongwm2026@163.com>
---
diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
index 209ef7522..d184893e5 100644
--- a/net/ipv4/tcp_ipv4.c
+++ b/net/ipv4/tcp_ipv4.c
@@ -2926,8 +2926,8 @@ static int bpf_iter_tcp_realloc_batch(struct bpf_tcp_iter_state *iter,
 {
 	union bpf_tcp_iter_batch_item *new_batch;
 
-	new_batch = kvmalloc(sizeof(*new_batch) * new_batch_sz,
-			     flags | __GFP_NOWARN);
+	new_batch = kvmalloc_array(new_batch_sz, sizeof(*new_batch),
+				   flags | __GFP_NOWARN);
 	if (!new_batch)
 		return -ENOMEM;
 


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-07-27 22:40 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-16  2:51 [PATCH] tcp: use kvmalloc_array() for BPF iterator batches Weimin Xiong
2026-07-27 22:40 ` patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox