From: Dakshaja Uppalapati <dakshaja@chelsio.com>
To: jgg@nvidia.com, dledford@redhat.com
Cc: linux-rdma@vger.kernel.org, bharat@chelsio.com, dakshaja@chelsio.com
Subject: [PATCH for-rc] iw_cxgb4: Fix refcount underflow while destroying cqs.
Date: Wed, 21 Jul 2021 16:51:55 +0530 [thread overview]
Message-ID: <1626866515-17895-1-git-send-email-dakshaja@chelsio.com> (raw)
Previous atomic increment decrement logic expects the atomic count
to be '0' after the final decrement. Replacing atomic count with
refcount does not allow that as refcount_dec() considers count of 1 as
underflow. Therefore fix the current refcount logic by decrementing
the refcount if one on the final deref in c4iw_destroy_cq().
Fixes: 7183451f846d (RDMA/cxgb4: Use refcount_t instead of atomic_t for reference counting")
Signed-off-by: Dakshaja Uppalapati <dakshaja@chelsio.com>
Reviewed-by: Potnuri Bharat Teja <bharat@chelsio.com>
---
drivers/infiniband/hw/cxgb4/cq.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/drivers/infiniband/hw/cxgb4/cq.c b/drivers/infiniband/hw/cxgb4/cq.c
index 6c8c910..54a5b60 100644
--- a/drivers/infiniband/hw/cxgb4/cq.c
+++ b/drivers/infiniband/hw/cxgb4/cq.c
@@ -976,8 +976,7 @@ int c4iw_destroy_cq(struct ib_cq *ib_cq, struct ib_udata *udata)
chp = to_c4iw_cq(ib_cq);
xa_erase_irq(&chp->rhp->cqs, chp->cq.cqid);
- refcount_dec(&chp->refcnt);
- wait_event(chp->wait, !refcount_read(&chp->refcnt));
+ wait_event(chp->wait, refcount_dec_if_one(&chp->refcnt));
ucontext = rdma_udata_to_drv_context(udata, struct c4iw_ucontext,
ibucontext);
--
1.8.3.1
next reply other threads:[~2021-07-21 11:39 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-07-21 11:21 Dakshaja Uppalapati [this message]
2021-07-22 7:43 ` [PATCH for-rc] iw_cxgb4: Fix refcount underflow while destroying cqs Leon Romanovsky
2021-07-22 12:06 ` Jason Gunthorpe
2021-07-22 12:57 ` Leon Romanovsky
2021-07-22 13:02 ` Jason Gunthorpe
2021-07-22 13:23 ` Dakshaja Uppalapati
2021-07-22 14:01 ` Leon Romanovsky
2021-07-22 14:02 ` Jason Gunthorpe
[not found] ` <20210803155919.GB11439@chelsio.com>
2021-08-03 16:09 ` Jason Gunthorpe
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=1626866515-17895-1-git-send-email-dakshaja@chelsio.com \
--to=dakshaja@chelsio.com \
--cc=bharat@chelsio.com \
--cc=dledford@redhat.com \
--cc=jgg@nvidia.com \
--cc=linux-rdma@vger.kernel.org \
/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;
as well as URLs for NNTP newsgroup(s).