diff options
author | Thorsten Blum <thorsten.blum@linux.dev> | 2024-09-28 17:00:30 +0200 |
---|---|---|
committer | Steve French <stfrench@microsoft.com> | 2024-10-01 14:50:51 -0500 |
commit | 9c383396362a4d1db99ed5240f4708d443361ef3 (patch) | |
tree | 8519cc113f5ae22ae30aec8f9059e777973decef /fs/smb | |
parent | 0801c1374ab1552bd7376370987142ff77912527 (diff) |
ksmbd: Use struct_size() to improve smb_direct_rdma_xmit()
Use struct_size() to calculate the number of bytes to allocate for a
new message.
Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
Acked-by: Namjae Jeon <linkinjeon@kernel.org>
Signed-off-by: Steve French <stfrench@microsoft.com>
Diffstat (limited to 'fs/smb')
-rw-r--r-- | fs/smb/server/transport_rdma.c | 4 |
1 files 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; |