Linux SCSI subsystem development
 help / color / mirror / Atom feed
* [PATCH] scsi: bnx2fc: Fix skb double free in bnx2fc_rcv()
@ 2022-11-14 11:06 Wei Yongjun
  2023-12-14 10:46 ` Dan Carpenter
  2023-12-19  2:19 ` Martin K. Petersen
  0 siblings, 2 replies; 4+ messages in thread
From: Wei Yongjun @ 2022-11-14 11:06 UTC (permalink / raw)
  To: Maurizio Lombardi, Chad Dupuis, Saurav Kashyap, Javed Hasan,
	GR-QLogic-Storage-Upstream, James E.J. Bottomley,
	Martin K. Petersen
  Cc: Wei Yongjun, linux-scsi

From: Wei Yongjun <weiyongjun1@huawei.com>

skb_share_check() already drop the reference of skb when return
NULL, using kfree_skb() in the error handling path lead to skb
double free.

Fix it by remve the variable tmp_skb, and return directly when
skb_share_check() return NULL.

Fixes: 01a4cc4d0cd6 ("bnx2fc: do not add shared skbs to the fcoe_rx_list")
Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
---
 drivers/scsi/bnx2fc/bnx2fc_fcoe.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/scsi/bnx2fc/bnx2fc_fcoe.c b/drivers/scsi/bnx2fc/bnx2fc_fcoe.c
index 05ddbb9bb7d8..451a58e0fd96 100644
--- a/drivers/scsi/bnx2fc/bnx2fc_fcoe.c
+++ b/drivers/scsi/bnx2fc/bnx2fc_fcoe.c
@@ -429,7 +429,6 @@ static int bnx2fc_rcv(struct sk_buff *skb, struct net_device *dev,
 	struct fcoe_ctlr *ctlr;
 	struct fcoe_rcv_info *fr;
 	struct fcoe_percpu_s *bg;
-	struct sk_buff *tmp_skb;
 
 	interface = container_of(ptype, struct bnx2fc_interface,
 				 fcoe_packet_type);
@@ -441,11 +440,9 @@ static int bnx2fc_rcv(struct sk_buff *skb, struct net_device *dev,
 		goto err;
 	}
 
-	tmp_skb = skb_share_check(skb, GFP_ATOMIC);
-	if (!tmp_skb)
-		goto err;
-
-	skb = tmp_skb;
+	skb = skb_share_check(skb, GFP_ATOMIC);
+	if (!skb)
+		return -1;
 
 	if (unlikely(eth_hdr(skb)->h_proto != htons(ETH_P_FCOE))) {
 		printk(KERN_ERR PFX "bnx2fc_rcv: Wrong FC type frame\n");
-- 
2.34.1


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

end of thread, other threads:[~2023-12-19  2:20 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-11-14 11:06 [PATCH] scsi: bnx2fc: Fix skb double free in bnx2fc_rcv() Wei Yongjun
2023-12-14 10:46 ` Dan Carpenter
2023-12-19  1:34   ` Martin K. Petersen
2023-12-19  2:19 ` Martin K. Petersen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox