Skip to content

Commit

Permalink
mac802154: fix memory leaks
Browse files Browse the repository at this point in the history
kfree_skb() was not getting called in the case of some failures.
This was pointed out by Eric Dumazet.

Signed-off-by: Alan Ott <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
signal11 authored and davem330 committed Nov 30, 2012
1 parent b333b7e commit fcefbe9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 4 additions & 1 deletion net/mac802154/tx.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand All @@ -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;
Expand Down
4 changes: 3 additions & 1 deletion net/mac802154/wpan.c
Original file line number Diff line number Diff line change
Expand Up @@ -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++;
Expand Down

0 comments on commit fcefbe9

Please sign in to comment.