From: Jia-Ju Bai <baijiaju1990@gmail.com>
To: bharat@chelsio.com, dledford@redhat.com, jgg@ziepe.ca
Cc: linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org,
Jia-Ju Bai <baijiaju1990@gmail.com>
Subject: [PATCH] infiniband: hw: cxgb3: Fix a possible null-pointer dereference in connect_reply_upcall()
Date: Thu, 25 Jul 2019 20:15:08 +0800 [thread overview]
Message-ID: <20190725121508.16352-1-baijiaju1990@gmail.com> (raw)
In connect_reply_upcall(), there is an if statement on line 730 to check
whether ep->com.cm_id is NULL:
if (ep->com.cm_id)
When ep->com.cm_id is NULL, it is used on line 736:
ep->com.cm_id->rem_ref(ep->com.cm_id);
Thus, a possible null-pointer dereference may occur.
To fix this bug, ep->com.cm_id is checked before being used.
This bug is found by a static analysis tool STCheck written by us.
Signed-off-by: Jia-Ju Bai <baijiaju1990@gmail.com>
---
drivers/infiniband/hw/cxgb3/iwch_cm.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/infiniband/hw/cxgb3/iwch_cm.c b/drivers/infiniband/hw/cxgb3/iwch_cm.c
index 0bca72cb4d9a..2b31c4726d3e 100644
--- a/drivers/infiniband/hw/cxgb3/iwch_cm.c
+++ b/drivers/infiniband/hw/cxgb3/iwch_cm.c
@@ -733,7 +733,8 @@ static void connect_reply_upcall(struct iwch_ep *ep, int status)
ep->com.cm_id->event_handler(ep->com.cm_id, &event);
}
if (status < 0) {
- ep->com.cm_id->rem_ref(ep->com.cm_id);
+ if (ep->com.cm_id)
+ ep->com.cm_id->rem_ref(ep->com.cm_id);
ep->com.cm_id = NULL;
ep->com.qp = NULL;
}
--
2.17.0
next reply other threads:[~2019-07-25 12:15 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-07-25 12:15 Jia-Ju Bai [this message]
2019-07-29 16:28 ` Doug Ledford
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=20190725121508.16352-1-baijiaju1990@gmail.com \
--to=baijiaju1990@gmail.com \
--cc=bharat@chelsio.com \
--cc=dledford@redhat.com \
--cc=jgg@ziepe.ca \
--cc=linux-kernel@vger.kernel.org \
--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
all inboxes | Powered by JetHome®