Skip to content

Commit 08c94d8

Browse files
Wei Yongjunmartinkpetersen
authored andcommitted
scsi: bnx2fc: Fix skb double free in bnx2fc_rcv()
skb_share_check() already drops the reference to the skb when returning NULL. Using kfree_skb() in the error handling path leads to an skb double free. Fix this by removing the variable tmp_skb, and return directly when skb_share_check() returns NULL. Fixes: 01a4cc4 ("bnx2fc: do not add shared skbs to the fcoe_rx_list") Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com> Link: https://lore.kernel.org/r/20221114110626.526643-1-weiyongjun@huaweicloud.com Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
1 parent 77a6725 commit 08c94d8

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

drivers/scsi/bnx2fc/bnx2fc_fcoe.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,6 @@ static int bnx2fc_rcv(struct sk_buff *skb, struct net_device *dev,
429429
struct fcoe_ctlr *ctlr;
430430
struct fcoe_rcv_info *fr;
431431
struct fcoe_percpu_s *bg;
432-
struct sk_buff *tmp_skb;
433432

434433
interface = container_of(ptype, struct bnx2fc_interface,
435434
fcoe_packet_type);
@@ -441,11 +440,9 @@ static int bnx2fc_rcv(struct sk_buff *skb, struct net_device *dev,
441440
goto err;
442441
}
443442

444-
tmp_skb = skb_share_check(skb, GFP_ATOMIC);
445-
if (!tmp_skb)
446-
goto err;
447-
448-
skb = tmp_skb;
443+
skb = skb_share_check(skb, GFP_ATOMIC);
444+
if (!skb)
445+
return -1;
449446

450447
if (unlikely(eth_hdr(skb)->h_proto != htons(ETH_P_FCOE))) {
451448
printk(KERN_ERR PFX "bnx2fc_rcv: Wrong FC type frame\n");

0 commit comments

Comments
 (0)