mirror of
https://github.com/torvalds/linux.git
synced 2024-11-24 21:21:41 +00:00
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>
This commit is contained in:
parent
0801c1374a
commit
9c38339636
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user