Linux RDMA and InfiniBand development
 help / color / mirror / Atom feed
* [PATCH net-next v2] net/rds: use krealloc_array() for iovector growth
@ 2026-07-17  2:23 Weimin Xiong
  0 siblings, 0 replies; 4+ messages in thread
From: Weimin Xiong @ 2026-07-17  2:23 UTC (permalink / raw)
  To: netdev; +Cc: linux-rdma

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>
Reviewed-by: Allison Henderson <achender@kernel.org>
---
 net/rds/send.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/net/rds/send.c b/net/rds/send.c
index 68be1bf0e..a567c97a 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;
--
2.39.3


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

* [PATCH net-next v2] net/rds: use krealloc_array() for iovector growth
@ 2026-07-17  2:25 Weimin Xiong
  0 siblings, 0 replies; 4+ messages in thread
From: Weimin Xiong @ 2026-07-17  2:25 UTC (permalink / raw)
  To: netdev
  Cc: linux-rdma, rds-devel, linux-kernel, davem, edumazet, kuba,
	pabeni, horms, achender

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.

Reviewed-by: Allison Henderson <achender@kernel.org>
Signed-off-by: Weimin Xiong <xiongwm2026@163.com>
---
 net/rds/send.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/net/rds/send.c b/net/rds/send.c
index 68be1bf0e..a567c97a 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;
--
2.39.3


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

* [PATCH net-next v2] net/rds: use krealloc_array() for iovector growth
@ 2026-07-17  2:25 Weimin Xiong
  2026-07-24 23:30 ` patchwork-bot+netdevbpf
  0 siblings, 1 reply; 4+ messages in thread
From: Weimin Xiong @ 2026-07-17  2:25 UTC (permalink / raw)
  To: netdev
  Cc: linux-rdma, rds-devel, linux-kernel, davem, edumazet, kuba,
	pabeni, horms

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.

Reviewed-by: Allison Henderson <achender@kernel.org>
Signed-off-by: Weimin Xiong <xiongwm2026@163.com>
---
 net/rds/send.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/net/rds/send.c b/net/rds/send.c
index 68be1bf0e..a567c97a 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;
--
2.39.3


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

* Re: [PATCH net-next v2] net/rds: use krealloc_array() for iovector growth
  2026-07-17  2:25 [PATCH net-next v2] net/rds: use krealloc_array() for iovector growth Weimin Xiong
@ 2026-07-24 23:30 ` patchwork-bot+netdevbpf
  0 siblings, 0 replies; 4+ messages in thread
From: patchwork-bot+netdevbpf @ 2026-07-24 23:30 UTC (permalink / raw)
  To: Weimin Xiong
  Cc: netdev, linux-rdma, rds-devel, linux-kernel, davem, edumazet,
	kuba, pabeni, horms

Hello:

This patch was applied to netdev/net-next.git (main)
by Jakub Kicinski <kuba@kernel.org>:

On Fri, 17 Jul 2026 10:25:37 +0800 you wrote:
> 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.
> 
> Reviewed-by: Allison Henderson <achender@kernel.org>
> Signed-off-by: Weimin Xiong <xiongwm2026@163.com>
> 
> [...]

Here is the summary with links:
  - [net-next,v2] net/rds: use krealloc_array() for iovector growth
    https://git.kernel.org/netdev/net-next/c/04026c998c24

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



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

end of thread, other threads:[~2026-07-24 23:30 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-17  2:25 [PATCH net-next v2] net/rds: use krealloc_array() for iovector growth Weimin Xiong
2026-07-24 23:30 ` patchwork-bot+netdevbpf
  -- strict thread matches above, loose matches on Subject: below --
2026-07-17  2:25 Weimin Xiong
2026-07-17  2:23 Weimin Xiong

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