Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

RDMA/bnxt_re: Use ib_respond_udata()

All the calls to ib_copy_to_udata() can use this helper safely.

Link: https://patch.msgid.link/r/11-v3-bd56dd443069+49-bnxt_re_uapi_jgg@nvidia.com
Tested-by: Sriharsha Basavapatna <sriharsha.basavapatna@broadcom.com>
Acked-by: Sriharsha Basavapatna <sriharsha.basavapatna@broadcom.com>
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>

+9 -22
+9 -22
drivers/infiniband/hw/bnxt_re/ib_verbs.c
··· 187 187 struct bnxt_re_dev *rdev = to_bnxt_re_dev(ibdev, ibdev); 188 188 struct bnxt_qplib_dev_attr *dev_attr = rdev->dev_attr; 189 189 struct bnxt_re_query_device_ex_resp resp = {}; 190 - size_t outlen = (udata) ? udata->outlen : 0; 191 190 int rc = 0; 192 191 193 192 rc = ib_is_udata_in_empty(udata); ··· 257 258 ib_attr->max_pkeys = 1; 258 259 ib_attr->local_ca_ack_delay = BNXT_RE_DEFAULT_ACK_DELAY; 259 260 260 - if ((offsetofend(typeof(resp), packet_pacing_caps) <= outlen) && 261 - _is_modify_qp_rate_limit_supported(dev_attr->dev_cap_flags2)) { 261 + if (_is_modify_qp_rate_limit_supported(dev_attr->dev_cap_flags2)) { 262 262 resp.packet_pacing_caps.qp_rate_limit_min = 263 263 dev_attr->rate_limit_min; 264 264 resp.packet_pacing_caps.qp_rate_limit_max = ··· 265 267 resp.packet_pacing_caps.supported_qpts = 266 268 1 << IB_QPT_RC; 267 269 } 268 - if (outlen) 269 - rc = ib_copy_to_udata(udata, &resp, 270 - min(sizeof(resp), outlen)); 271 - 272 - return rc; 270 + return ib_respond_udata(udata, resp); 273 271 } 274 272 275 273 int bnxt_re_modify_device(struct ib_device *ibdev, ··· 763 769 764 770 pd->pd_db_mmap = &entry->rdma_entry; 765 771 766 - rc = ib_copy_to_udata(udata, &resp, min(sizeof(resp), udata->outlen)); 772 + rc = ib_respond_udata(udata, resp); 767 773 if (rc) { 768 774 rdma_user_mmap_entry_remove(pd->pd_db_mmap); 769 775 rc = -EFAULT; ··· 1721 1727 1722 1728 resp.qpid = qp->qplib_qp.id; 1723 1729 resp.rsvd = 0; 1724 - rc = ib_copy_to_udata(udata, &resp, sizeof(resp)); 1725 - if (rc) { 1726 - ibdev_err(&rdev->ibdev, "Failed to copy QP udata"); 1730 + rc = ib_respond_udata(udata, resp); 1731 + if (rc) 1727 1732 goto qp_destroy; 1728 - } 1729 1733 } 1730 1734 } 1731 1735 ··· 1982 1990 } 1983 1991 resp.comp_mask |= BNXT_RE_SRQ_TOGGLE_PAGE_SUPPORT; 1984 1992 } 1985 - rc = ib_copy_to_udata(udata, &resp, sizeof(resp)); 1993 + rc = ib_respond_udata(udata, resp); 1986 1994 if (rc) { 1987 - ibdev_err(&rdev->ibdev, "SRQ copy to udata failed!"); 1988 1995 bnxt_qplib_destroy_srq(&rdev->qplib_res, 1989 1996 &srq->qplib_srq); 1990 1997 goto fail; ··· 3272 3281 resp.tail = cq->qplib_cq.hwq.cons; 3273 3282 resp.phase = cq->qplib_cq.period; 3274 3283 resp.rsvd = 0; 3275 - rc = ib_copy_to_udata(udata, &resp, min(sizeof(resp), udata->outlen)); 3284 + rc = ib_respond_udata(udata, resp); 3276 3285 if (rc) { 3277 - ibdev_err(&rdev->ibdev, "Failed to copy CQ udata"); 3278 3286 bnxt_qplib_destroy_cq(&rdev->qplib_res, &cq->qplib_cq); 3279 3287 goto free_mem; 3280 3288 } ··· 4479 4489 } 4480 4490 } 4481 4491 4482 - rc = ib_copy_to_udata(udata, &resp, min(udata->outlen, sizeof(resp))); 4483 - if (rc) { 4484 - ibdev_err(ibdev, "Failed to copy user context"); 4485 - rc = -EFAULT; 4492 + rc = ib_respond_udata(udata, resp); 4493 + if (rc) 4486 4494 goto cfail; 4487 - } 4488 4495 4489 4496 return 0; 4490 4497 cfail: