public inbox for linux-rdma@vger.kernel.org
 help / color / mirror / Atom feed
From: Jason Gunthorpe <jgg@ziepe.ca>
To: Sriharsha Basavapatna <sriharsha.basavapatna@broadcom.com>
Cc: leon@kernel.org, linux-rdma@vger.kernel.org,
	andrew.gospodarek@broadcom.com, selvin.xavier@broadcom.com,
	kalesh-anakkur.purayil@broadcom.com
Subject: Re: [PATCH rdma-next v6 4/4] RDMA/bnxt_re: Direct Verbs: Support CQ and QP verbs
Date: Fri, 9 Jan 2026 15:37:56 -0400	[thread overview]
Message-ID: <20260109193756.GP545276@ziepe.ca> (raw)
In-Reply-To: <20251224042602.56255-5-sriharsha.basavapatna@broadcom.com>

On Wed, Dec 24, 2025 at 09:56:02AM +0530, Sriharsha Basavapatna wrote:
> +static int bnxt_re_dv_create_qplib_cq(struct bnxt_re_dev *rdev,
> +				      struct bnxt_re_ucontext *re_uctx,
> +				      struct bnxt_re_cq *cq,
> +				      struct bnxt_re_cq_req *req)
> +{
> +	struct bnxt_qplib_dev_attr *dev_attr = rdev->dev_attr;
> +	struct bnxt_qplib_cq *qplcq;
> +	struct ib_umem *umem;
> +	u32 cqe = req->ncqe;
> +	u32 max_active_cqs;
> +	int rc = -EINVAL;
> +
> +	if (atomic_read(&rdev->stats.res.cq_count) >= dev_attr->max_cq) {
> +		ibdev_dbg(&rdev->ibdev, "Create CQ failed - max exceeded(CQs)");
> +		return rc;
> +	}

This is a racy way to use atomics, this should be an
atomic_inc_return, then check the return code, doing a dec on all
error paths.

> +static void bnxt_re_dv_init_ib_cq(struct bnxt_re_dev *rdev,
> +				  struct bnxt_re_cq *re_cq)
> +{
> +	struct ib_cq *ib_cq;
> +
> +	ib_cq = &re_cq->ib_cq;
> +	ib_cq->device = &rdev->ibdev;


> +	ib_cq->uobject = NULL;
> +	ib_cq->comp_handler  = NULL;
> +	ib_cq->event_handler = NULL;
> +	atomic_set(&ib_cq->usecnt, 0);
> +}

All these should already be 0 since this was freshly zallocated, no?

> +int bnxt_re_dv_create_cq(struct bnxt_re_dev *rdev, struct ib_udata *udata,
> +			 struct bnxt_re_cq *re_cq, struct bnxt_re_cq_req *req)
> +{
> +	struct bnxt_re_ucontext *re_uctx =
> +		rdma_udata_to_drv_context(udata, struct bnxt_re_ucontext, ib_uctx);
> +	struct bnxt_re_cq_resp resp = {};
> +	int ret;
> +
> +	ret = bnxt_re_dv_create_qplib_cq(rdev, re_uctx, re_cq, req);
> +	if (ret)
> +		return ret;
> +
> +	ret = bnxt_re_dv_create_cq_resp(rdev, re_cq, &resp);
> +	if (ret)
> +		goto fail_resp;
> +
> +	ret = ib_copy_to_udata(udata, &resp, min(sizeof(resp), udata->outlen));
> +	if (ret)
> +		goto fail_resp;
> +
> +	bnxt_re_dv_init_ib_cq(rdev, re_cq);
> +	re_cq->is_dv_cq = true;
> +	atomic_inc(&rdev->dv_cq_count);
> +	return 0;
> +
> +fail_resp:
> +	bnxt_qplib_destroy_cq(&rdev->qplib_res, &re_cq->qplib_cq);
> +	bnxt_re_put_nq(rdev, re_cq->qplib_cq.nq);
> +	ib_umem_release(re_cq->umem);

This seems really weird error unwinding, I expect to see functions
with error unwinds that match the calls within the function.

So why doesn't bnxt_qplib_destroy_cq() do the umem release and
req_put_nq?

Jason

  parent reply	other threads:[~2026-01-09 19:37 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-12-24  4:25 [PATCH rdma-next v6 0/4] RDMA/bnxt_re: Support direct verbs Sriharsha Basavapatna
2025-12-24  4:25 ` [PATCH rdma-next v6 1/4] RDMA/bnxt_re: Move the UAPI methods to a dedicated file Sriharsha Basavapatna
2025-12-24  4:26 ` [PATCH rdma-next v6 2/4] RDMA/bnxt_re: Refactor bnxt_qplib_create_qp() function Sriharsha Basavapatna
2025-12-24  4:26 ` [PATCH rdma-next v6 3/4] RDMA/bnxt_re: Direct Verbs: Support DBR verbs Sriharsha Basavapatna
2026-01-09 18:35   ` Jason Gunthorpe
2026-01-13 17:13     ` Sriharsha Basavapatna
2026-01-09 18:50   ` Jason Gunthorpe
2026-01-13 17:13     ` Sriharsha Basavapatna
2026-01-09 18:55   ` Jason Gunthorpe
2026-01-13 17:13     ` Sriharsha Basavapatna
2026-01-09 19:01   ` Jason Gunthorpe
2026-01-13 17:14     ` Sriharsha Basavapatna
2025-12-24  4:26 ` [PATCH rdma-next v6 4/4] RDMA/bnxt_re: Direct Verbs: Support CQ and QP verbs Sriharsha Basavapatna
2026-01-09 18:37   ` Jason Gunthorpe
2026-01-13 17:13     ` Sriharsha Basavapatna
2026-01-09 19:08   ` Jason Gunthorpe
2026-01-13 17:14     ` Sriharsha Basavapatna
2026-01-13 17:27       ` Jason Gunthorpe
2026-01-17  8:07         ` Sriharsha Basavapatna
2026-01-09 19:37   ` Jason Gunthorpe [this message]
2026-01-13 17:15     ` Sriharsha Basavapatna
2026-01-13 17:28       ` Jason Gunthorpe
2026-01-17  8:07         ` Sriharsha Basavapatna

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260109193756.GP545276@ziepe.ca \
    --to=jgg@ziepe.ca \
    --cc=andrew.gospodarek@broadcom.com \
    --cc=kalesh-anakkur.purayil@broadcom.com \
    --cc=leon@kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    --cc=selvin.xavier@broadcom.com \
    --cc=sriharsha.basavapatna@broadcom.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox