diff mbox series

scsi: bnx2fc: fix double free of skb in bnx2fc_rcv

Message ID 20211228030335.1330070-1-yinxiujiang@kylinos.cn
State New
Headers show
Series scsi: bnx2fc: fix double free of skb in bnx2fc_rcv | expand

Commit Message

Yin Xiujiang Dec. 28, 2021, 3:03 a.m. UTC
In `bnx2fc_rcv`,if skb_share_check() return NULL,
the variable skb would be freed but not set to NULL,
then it would be freed  in `goto err` again.

Signed-off-by: Yin Xiujiang <yinxiujiang@kylinos.cn>
---
 drivers/scsi/bnx2fc/bnx2fc_fcoe.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
diff mbox series

Patch

diff --git a/drivers/scsi/bnx2fc/bnx2fc_fcoe.c b/drivers/scsi/bnx2fc/bnx2fc_fcoe.c
index 71fa62bd3083..07a91b1f05a2 100644
--- a/drivers/scsi/bnx2fc/bnx2fc_fcoe.c
+++ b/drivers/scsi/bnx2fc/bnx2fc_fcoe.c
@@ -432,7 +432,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);
@@ -444,11 +443,10 @@  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)
+	skb = skb_share_check(skb, GFP_ATOMIC);
+	if (unlikely(!skb))
 		goto err;
 
-	skb = tmp_skb;
 
 	if (unlikely(eth_hdr(skb)->h_proto != htons(ETH_P_FCOE))) {
 		printk(KERN_ERR PFX "bnx2fc_rcv: Wrong FC type frame\n");