mac802154: fix memory leaks
authorAlan Ott <alan@signal11.us>
Thu, 29 Nov 2012 18:25:10 +0000 (18:25 +0000)
committerDavid S. Miller <davem@davemloft.net>
Fri, 30 Nov 2012 17:19:24 +0000 (12:19 -0500)
kfree_skb() was not getting called in the case of some failures.
This was pointed out by Eric Dumazet.

Signed-off-by: Alan Ott <alan@signal11.us>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/mac802154/tx.c
net/mac802154/wpan.c

index 1a4df39c722e3d0b871105ea0ff30099a1ed37a1..db639140afc6735bcf7d2fc48d1b0a56ccb4460a 100644 (file)
@@ -85,6 +85,7 @@ netdev_tx_t mac802154_tx(struct mac802154_priv *priv, struct sk_buff *skb,
 
        if (!(priv->phy->channels_supported[page] & (1 << chan))) {
                WARN_ON(1);
+               kfree_skb(skb);
                return NETDEV_TX_OK;
        }
 
@@ -103,8 +104,10 @@ netdev_tx_t mac802154_tx(struct mac802154_priv *priv, struct sk_buff *skb,
        }
 
        work = kzalloc(sizeof(struct xmit_work), GFP_ATOMIC);
-       if (!work)
+       if (!work) {
+               kfree_skb(skb);
                return NETDEV_TX_BUSY;
+       }
 
        INIT_WORK(&work->work, mac802154_xmit_worker);
        work->skb = skb;
index f30f6d4beea178ed46750131e5840decd8c5238a..1191039c2b1bc38bda25402dd395d7e3b1bbe7b4 100644 (file)
@@ -327,8 +327,10 @@ mac802154_wpan_xmit(struct sk_buff *skb, struct net_device *dev)
 
        if (chan == MAC802154_CHAN_NONE ||
            page >= WPAN_NUM_PAGES ||
-           chan >= WPAN_NUM_CHANNELS)
+           chan >= WPAN_NUM_CHANNELS) {
+               kfree_skb(skb);
                return NETDEV_TX_OK;
+       }
 
        skb->skb_iif = dev->ifindex;
        dev->stats.tx_packets++;