public inbox for linux-rdma@vger.kernel.org
 help / color / mirror / Atom feed
From: Bob Pearson <rpearsonhpe@gmail.com>
To: jgg@nvidia.com, zyjzyj2000@gmail.com, jhack@hpe.com,
	matsuda-daisuke@fujitsu.com, linux-rdma@vger.kernel.org
Cc: Bob Pearson <rpearsonhpe@gmail.com>
Subject: [PATCH for-next v3 2/8] RDMA/rxe: Warn if refcnt zero in rxe_put
Date: Sat,  4 Mar 2023 11:45:28 -0600	[thread overview]
Message-ID: <20230304174533.11296-3-rpearsonhpe@gmail.com> (raw)
In-Reply-To: <20230304174533.11296-1-rpearsonhpe@gmail.com>

This patch adds a WARN_ON if the reference count of the object
passed to __rxe_put() is <= 0. This can only happen if there is a
bug in the rxe driver but has bad consequences if there is.

Signed-off-by: Bob Pearson <rpearsonhpe@gmail.com>
---
 drivers/infiniband/sw/rxe/rxe_pool.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/infiniband/sw/rxe/rxe_pool.c b/drivers/infiniband/sw/rxe/rxe_pool.c
index 3f6bd672cc2d..1b160e36b751 100644
--- a/drivers/infiniband/sw/rxe/rxe_pool.c
+++ b/drivers/infiniband/sw/rxe/rxe_pool.c
@@ -244,6 +244,8 @@ int __rxe_get(struct rxe_pool_elem *elem)
 
 int __rxe_put(struct rxe_pool_elem *elem)
 {
+	if (WARN_ON(kref_read(&elem->ref_cnt) <= 0))
+		return 0;
 	return kref_put(&elem->ref_cnt, rxe_elem_release);
 }
 
-- 
2.37.2


  parent reply	other threads:[~2023-03-04 17:46 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-04 17:45 [PATCH for-next v3 0/8] RDMA/rxe: Correct qp reference counting Bob Pearson
2023-03-04 17:45 ` [PATCH for-next v3 1/8] RDMA/rxe: Convert tasklet args to queue pairs Bob Pearson
2023-03-04 17:45 ` Bob Pearson [this message]
2023-03-24 14:18   ` [PATCH for-next v3 2/8] RDMA/rxe: Warn if refcnt zero in rxe_put Jason Gunthorpe
2023-03-04 17:45 ` [PATCH for-next v3 3/8] RDMA/rxe: Cleanup reset state handling in rxe_resp.c Bob Pearson
2023-03-04 17:45 ` [PATCH for-next v3 4/8] RDMA/rxe: Cleanup error state handling in rxe_comp.c Bob Pearson
2023-03-04 17:45 ` [PATCH for-next v3 5/8] RDMA/rxe: Remove qp reference counting in tasks Bob Pearson
2023-03-04 17:45 ` [PATCH for-next v3 6/8] RDMA/rxe: Remove __rxe_do_task() Bob Pearson
2023-03-04 17:45 ` [PATCH for-next v3 7/8] RDMA/rxe: Make tasks schedule each other Bob Pearson
2023-03-04 17:45 ` [PATCH for-next v3 8/8] RDMA/rxe: Rewrite rxe_task.c Bob Pearson
2023-03-24 14:23 ` [PATCH for-next v3 0/8] RDMA/rxe: Correct qp reference counting 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=20230304174533.11296-3-rpearsonhpe@gmail.com \
    --to=rpearsonhpe@gmail.com \
    --cc=jgg@nvidia.com \
    --cc=jhack@hpe.com \
    --cc=linux-rdma@vger.kernel.org \
    --cc=matsuda-daisuke@fujitsu.com \
    --cc=zyjzyj2000@gmail.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