Target-devel archive mirror
 help / color / mirror / Atom feed
From: Denis Plotnikov <den-plotnikov@yandex-team.ru>
To: linux-scsi@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, target-devel@vger.kernel.org,
	martin.petersen@oracle.com, nab@linux-iscsi.org,
	varun@chelsio.com, den-plotnikov@yandex-team.ru
Subject: [PATCH] cxgbit: check skb dequeue result in cxgbit_send_tx_flowc_wr()
Date: Fri,  7 Apr 2023 10:56:03 +0300	[thread overview]
Message-ID: <20230407075603.311230-1-den-plotnikov@yandex-team.ru> (raw)

Skb dequeuing may end up with returning NULL if a queue is empty,
which, in turn, may end up with further null pointer dereference.

Fix it by checking the return value of skb dequeuing end returning
before the pointer dereference.

Found by Linux Verification Center(linuxtesting.org) with SVACE.

Fixes: 9730ffcb8957 ("cxgbit: add files for cxgbit.ko")
Signed-off-by: Denis Plotnikov <den-plotnikov@yandex-team.ru>
---
 drivers/target/iscsi/cxgbit/cxgbit_cm.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/target/iscsi/cxgbit/cxgbit_cm.c b/drivers/target/iscsi/cxgbit/cxgbit_cm.c
index d9204c590d9ab..426a5c795fd93 100644
--- a/drivers/target/iscsi/cxgbit/cxgbit_cm.c
+++ b/drivers/target/iscsi/cxgbit/cxgbit_cm.c
@@ -1424,10 +1424,13 @@ u32 cxgbit_send_tx_flowc_wr(struct cxgbit_sock *csk)
 #ifdef CONFIG_CHELSIO_T4_DCB
 	u16 vlan = ((struct l2t_entry *)csk->l2t)->vlan;
 #endif
+	skb = __skb_dequeue(&csk->skbq);
+
+	if (!skb)
+		return 0;
 
 	flowclen16 = cxgbit_tx_flowc_wr_credits(csk, &nparams, &flowclen);
 
-	skb = __skb_dequeue(&csk->skbq);
 	flowc = __skb_put_zero(skb, flowclen);
 
 	flowc->op_to_nparams = cpu_to_be32(FW_WR_OP_V(FW_FLOWC_WR) |
-- 
2.25.1


             reply	other threads:[~2023-04-07  7:56 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-07  7:56 Denis Plotnikov [this message]
2023-04-10 11:49 ` [PATCH] cxgbit: check skb dequeue result in cxgbit_send_tx_flowc_wr() Varun Prakash

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=20230407075603.311230-1-den-plotnikov@yandex-team.ru \
    --to=den-plotnikov@yandex-team.ru \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    --cc=nab@linux-iscsi.org \
    --cc=target-devel@vger.kernel.org \
    --cc=varun@chelsio.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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).