fm10k: fix memory leak
authorstephen hemminger <shemming@brocade.com>
Tue, 17 Nov 2015 22:24:27 +0000 (14:24 -0800)
committerDavid S. Miller <davem@davemloft.net>
Wed, 18 Nov 2015 19:58:03 +0000 (14:58 -0500)
This was detected by Coverity.
The function skb_cow_head leaves skb alone on failure, so caller needs
to free.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/intel/fm10k/fm10k_netdev.c

index 639263d5e833a04d19967f6df3cd20d8ce574a3b..7781e80896a60a59e12eec15582cc3743447e1dd 100644 (file)
@@ -627,8 +627,10 @@ static netdev_tx_t fm10k_xmit_frame(struct sk_buff *skb, struct net_device *dev)
 
                /* verify the skb head is not shared */
                err = skb_cow_head(skb, 0);
-               if (err)
+               if (err) {
+                       dev_kfree_skb(skb);
                        return NETDEV_TX_OK;
+               }
 
                /* locate vlan header */
                vhdr = (struct vlan_hdr *)(skb->data + ETH_HLEN);