All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] rds: use krealloc_array() for iovector growth
@ 2026-07-16  2:51 Weimin Xiong
  2026-07-17  1:00 ` Allison Henderson
  0 siblings, 1 reply; 2+ messages in thread
From: Weimin Xiong @ 2026-07-16  2:51 UTC (permalink / raw)
  To: Allison Henderson
  Cc: netdev, linux-rdma, rds-devel, linux-kernel, David S . Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni, Simon Horman,
	Weimin Xiong

Use krealloc_array() for growing the RDS iovector array. This makes the
array allocation overflow-safe and derives the element size from the
array pointer.

Signed-off-by: Weimin Xiong <xiongwm2026@163.com>
---
diff --git a/net/rds/send.c b/net/rds/send.c
index 68be1bf0e..6a567c97a 100644
--- a/net/rds/send.c
+++ b/net/rds/send.c
@@ -971,11 +971,8 @@ static int rds_rm_size(struct msghdr *msg, int num_sgs,
 				return -EINVAL;
 			if (vct->indx >= vct->len) {
 				vct->len += vct->incr;
-				tmp_iov =
-					krealloc(vct->vec,
-						 vct->len *
-						 sizeof(struct rds_iov_vector),
-						 GFP_KERNEL);
+				tmp_iov = krealloc_array(vct->vec, vct->len,
+							 sizeof(*vct->vec), GFP_KERNEL);
 				if (!tmp_iov) {
 					vct->len -= vct->incr;
 					return -ENOMEM;


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

end of thread, other threads:[~2026-07-17  1:00 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] rds: use krealloc_array() for iovector growth Weimin Xiong
2026-07-17  1:00 ` Allison Henderson

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.