]> Git Repo - linux.git/commitdiff
ksmbd: Use struct_size() to improve smb_direct_rdma_xmit()
authorThorsten Blum <[email protected]>
Sat, 28 Sep 2024 15:00:30 +0000 (17:00 +0200)
committerSteve French <[email protected]>
Tue, 1 Oct 2024 19:50:51 +0000 (14:50 -0500)
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]>
fs/smb/server/transport_rdma.c

index 44c87e300c161a01b3812eae7795f8c600b458fc..17c76713c6d08617d0edea67543da3994328f58f 100644 (file)
@@ -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;
This page took 0.056444 seconds and 4 git commands to generate.