From: Dan Carpenter <dan.carpenter@oracle.com>
To: Potnuri Bharat Teja <bharat@chelsio.com>,
Steve Wise <larrystevenwise@gmail.com>
Cc: Jason Gunthorpe <jgg@ziepe.ca>,
Doug Ledford <dledford@redhat.com>,
linux-rdma@vger.kernel.org, kernel-janitors@vger.kernel.org
Subject: [PATCH] RDMA/cxgb4: fix refcounting leak in c4iw_ref_send_wait()
Date: Mon, 24 Jan 2022 15:25:02 +0300 [thread overview]
Message-ID: <20220124122502.GB31673@kili> (raw)
Call c4iw_put_wr_wait() if c4iw_wait_for_reply() fails. This
code uses kobject so the worst impact from this bug is a DoS.
Fixes: 2015f26cfade ("iw_cxgb4: add referencing to wait objects")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
From static analysis. Not tested.
drivers/infiniband/hw/cxgb4/iw_cxgb4.h | 17 ++++++++++++-----
1 file changed, 12 insertions(+), 5 deletions(-)
diff --git a/drivers/infiniband/hw/cxgb4/iw_cxgb4.h b/drivers/infiniband/hw/cxgb4/iw_cxgb4.h
index 12f33467c672..1dc0e00aba5f 100644
--- a/drivers/infiniband/hw/cxgb4/iw_cxgb4.h
+++ b/drivers/infiniband/hw/cxgb4/iw_cxgb4.h
@@ -297,11 +297,18 @@ static inline int c4iw_ref_send_wait(struct c4iw_rdev *rdev,
qpid);
c4iw_get_wr_wait(wr_waitp);
ret = c4iw_ofld_send(rdev, skb);
- if (ret) {
- c4iw_put_wr_wait(wr_waitp);
- return ret;
- }
- return c4iw_wait_for_reply(rdev, wr_waitp, hwtid, qpid, func);
+ if (ret)
+ goto put_wait;
+
+ ret = c4iw_wait_for_reply(rdev, wr_waitp, hwtid, qpid, func);
+ if (ret)
+ goto put_wait;
+
+ return 0;
+
+put_wait:
+ c4iw_put_wr_wait(wr_waitp);
+ return ret;
}
enum db_state {
--
2.20.1
next reply other threads:[~2022-01-24 12:25 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-24 12:25 Dan Carpenter [this message]
2022-01-28 17:16 ` [PATCH] RDMA/cxgb4: fix refcounting leak in c4iw_ref_send_wait() Jason Gunthorpe
2022-01-28 19:52 ` Dan Carpenter
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=20220124122502.GB31673@kili \
--to=dan.carpenter@oracle.com \
--cc=bharat@chelsio.com \
--cc=dledford@redhat.com \
--cc=jgg@ziepe.ca \
--cc=kernel-janitors@vger.kernel.org \
--cc=larrystevenwise@gmail.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).