Skip to content

Commit 9c38339

Browse files
tobluxSteve French
authored andcommitted
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 <[email protected]> Acked-by: Namjae Jeon <[email protected]> Signed-off-by: Steve French <[email protected]>
1 parent 0801c13 commit 9c38339

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

fs/smb/server/transport_rdma.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1405,8 +1405,8 @@ static int smb_direct_rdma_xmit(struct smb_direct_transport *t,
14051405
/* build rdma_rw_ctx for each descriptor */
14061406
desc_buf = buf;
14071407
for (i = 0; i < desc_num; i++) {
1408-
msg = kzalloc(offsetof(struct smb_direct_rdma_rw_msg, sg_list) +
1409-
sizeof(struct scatterlist) * SG_CHUNK_SIZE, GFP_KERNEL);
1408+
msg = kzalloc(struct_size(msg, sg_list, SG_CHUNK_SIZE),
1409+
GFP_KERNEL);
14101410
if (!msg) {
14111411
ret = -ENOMEM;
14121412
goto out;

0 commit comments

Comments
 (0)