hinic: skb_pad() frees on error
authorDan Carpenter <dan.carpenter@oracle.com>
Fri, 25 Aug 2017 08:24:28 +0000 (11:24 +0300)
committerDavid S. Miller <davem@davemloft.net>
Sat, 26 Aug 2017 00:13:04 +0000 (17:13 -0700)
The skb_pad() function frees the skb on error, so this code has a double
free.

Fixes: 00e57a6d4ad3 ("net-next/hinic: Add Tx operation")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/huawei/hinic/hinic_tx.c

index 5bf6a32faa46ee238d27f007429ee66c9aa1efe9..abe3e38cd3423e21f5acc7d8e42940168669c5e3 100644 (file)
@@ -192,7 +192,7 @@ netdev_tx_t hinic_xmit_frame(struct sk_buff *skb, struct net_device *netdev)
        if (skb->len < MIN_SKB_LEN) {
                if (skb_pad(skb, MIN_SKB_LEN - skb->len)) {
                        netdev_err(netdev, "Failed to pad skb\n");
-                       goto skb_error;
+                       goto update_error_stats;
                }
 
                skb->len = MIN_SKB_LEN;
@@ -237,6 +237,7 @@ flush_skbs:
 skb_error:
        dev_kfree_skb_any(skb);
 
+update_error_stats:
        u64_stats_update_begin(&txq->txq_stats.syncp);
        txq->txq_stats.tx_dropped++;
        u64_stats_update_end(&txq->txq_stats.syncp);