mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] cxgbit: check skb dequeue result in cxgbit_send_tx_flowc_wr()
@ 2023-04-07  7:56 Denis Plotnikov
  2023-04-10 11:49 ` Varun Prakash
  0 siblings, 1 reply; 2+ messages in thread
From: Denis Plotnikov @ 2023-04-07  7:56 UTC (permalink / raw)
  To: linux-scsi
  Cc: linux-kernel, target-devel, martin.petersen, nab, varun, den-plotnikov

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


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-04-10 11:49 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-07  7:56 [PATCH] cxgbit: check skb dequeue result in cxgbit_send_tx_flowc_wr() Denis Plotnikov
2023-04-10 11:49 ` Varun Prakash

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®