* [PATCH] ksmbd: Use struct_size() to improve smb_direct_rdma_xmit()
@ 2024-09-28 15:00 Thorsten Blum
2024-10-01 4:31 ` Namjae Jeon
0 siblings, 1 reply; 2+ messages in thread
From: Thorsten Blum @ 2024-09-28 15:00 UTC (permalink / raw)
To: Namjae Jeon, Steve French, Sergey Senozhatsky, Tom Talpey
Cc: Thorsten Blum, linux-cifs, linux-kernel
Use struct_size() to calculate the number of bytes to allocate for a
new message.
Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
---
fs/smb/server/transport_rdma.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/fs/smb/server/transport_rdma.c b/fs/smb/server/transport_rdma.c
index 44c87e300c16..17c76713c6d0 100644
--- a/fs/smb/server/transport_rdma.c
+++ b/fs/smb/server/transport_rdma.c
@@ -1405,8 +1405,8 @@ static int smb_direct_rdma_xmit(struct smb_direct_transport *t,
/* build rdma_rw_ctx for each descriptor */
desc_buf = buf;
for (i = 0; i < desc_num; i++) {
- msg = kzalloc(offsetof(struct smb_direct_rdma_rw_msg, sg_list) +
- sizeof(struct scatterlist) * SG_CHUNK_SIZE, GFP_KERNEL);
+ msg = kzalloc(struct_size(msg, sg_list, SG_CHUNK_SIZE),
+ GFP_KERNEL);
if (!msg) {
ret = -ENOMEM;
goto out;
--
2.46.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-10-01 4:31 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-28 15:00 [PATCH] ksmbd: Use struct_size() to improve smb_direct_rdma_xmit() Thorsten Blum
2024-10-01 4:31 ` Namjae Jeon
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox