Skip to content

Commit

Permalink
ksmbd: Use struct_size() to improve smb_direct_rdma_xmit()
Browse files Browse the repository at this point in the history
Use struct_size() to calculate the number of bytes to allocate for a
new message.

Signed-off-by: Thorsten Blum <[email protected]>
Signed-off-by: Namjae Jeon <[email protected]>
  • Loading branch information
toblux authored and namjaejeon committed Oct 14, 2024
1 parent 11a419c commit 0ee56e8
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions transport_rdma.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 0ee56e8

Please sign in to comment.