Skip to content

Commit 1b479fb

Browse files
Yunlongsdavem330
authored andcommitted
drivers/net/wan/hdlc_fr: Fix a double free in pvc_xmit
In pvc_xmit, if __skb_pad(skb, pad, false) failed, it will free the skb in the first time and goto drop. But the same skb is freed by kfree_skb(skb) in the second time in drop. Maintaining the original function unchanged, my patch adds a new label out to avoid the double free if __skb_pad() failed. Fixes: f5083d0 ("drivers/net/wan/hdlc_fr: Improvements to the code of pvc_xmit") Signed-off-by: Lv Yunlong <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 75887e8 commit 1b479fb

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

drivers/net/wan/hdlc_fr.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,7 @@ static netdev_tx_t pvc_xmit(struct sk_buff *skb, struct net_device *dev)
415415

416416
if (pad > 0) { /* Pad the frame with zeros */
417417
if (__skb_pad(skb, pad, false))
418-
goto drop;
418+
goto out;
419419
skb_put(skb, pad);
420420
}
421421
}
@@ -448,8 +448,9 @@ static netdev_tx_t pvc_xmit(struct sk_buff *skb, struct net_device *dev)
448448
return NETDEV_TX_OK;
449449

450450
drop:
451-
dev->stats.tx_dropped++;
452451
kfree_skb(skb);
452+
out:
453+
dev->stats.tx_dropped++;
453454
return NETDEV_TX_OK;
454455
}
455456

0 commit comments

Comments
 (0)