]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
RDMA/cxgb4: Convert to ib_respond_udata()
authorJason Gunthorpe <jgg@nvidia.com>
Tue, 12 May 2026 00:09:34 +0000 (21:09 -0300)
committerLeon Romanovsky <leon@kernel.org>
Mon, 18 May 2026 08:58:42 +0000 (04:58 -0400)
These cases carefully work around 32-bit unpadded structures, but
the min integrated into ib_respond_udata() handles this
automatically. Zero-initialize data that would not have been copied.

Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
Signed-off-by: Leon Romanovsky <leon@kernel.org>
drivers/infiniband/hw/cxgb4/cq.c
drivers/infiniband/hw/cxgb4/provider.c

index e31fb9134aa8185be2b42e6a29a89f5284d8f4f5..47508df4cec023ded6846d12486c9ade85f9d830 100644 (file)
@@ -1115,13 +1115,11 @@ int c4iw_create_cq(struct ib_cq *ibcq, const struct ib_cq_init_attr *attr,
                /* communicate to the userspace that
                 * kernel driver supports 64B CQE
                 */
-               uresp.flags |= C4IW_64B_CQE;
+               if (!ucontext->is_32b_cqe)
+                       uresp.flags |= C4IW_64B_CQE;
 
                spin_unlock(&ucontext->mmap_lock);
-               ret = ib_copy_to_udata(udata, &uresp,
-                                      ucontext->is_32b_cqe ?
-                                      sizeof(uresp) - sizeof(uresp.flags) :
-                                      sizeof(uresp));
+               ret = ib_respond_udata(udata, uresp);
                if (ret)
                        goto err_free_mm2;
 
index a119e8793aef40bef8da3c236e52492eab967a91..0e3827022c63da4b9bf7b1ad62301f01df8a56b8 100644 (file)
@@ -80,7 +80,7 @@ static int c4iw_alloc_ucontext(struct ib_ucontext *ucontext,
        struct ib_device *ibdev = ucontext->device;
        struct c4iw_ucontext *context = to_c4iw_ucontext(ucontext);
        struct c4iw_dev *rhp = to_c4iw_dev(ibdev);
-       struct c4iw_alloc_ucontext_resp uresp;
+       struct c4iw_alloc_ucontext_resp uresp = {};
        int ret = 0;
        struct c4iw_mm_entry *mm = NULL;
 
@@ -106,8 +106,7 @@ static int c4iw_alloc_ucontext(struct ib_ucontext *ucontext,
                context->key += PAGE_SIZE;
                spin_unlock(&context->mmap_lock);
 
-               ret = ib_copy_to_udata(udata, &uresp,
-                                      sizeof(uresp) - sizeof(uresp.reserved));
+               ret = ib_respond_udata(udata, uresp);
                if (ret)
                        goto err_mm;