2012-11-30 04:25:13

by Alan Ott

[permalink] [raw]
Subject: [PATCH 1/2] mac802154: fix memory leaks

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]>
---
net/mac802154/tx.c | 5 ++++-
net/mac802154/wpan.c | 4 +++-
2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/net/mac802154/tx.c b/net/mac802154/tx.c
index 1a4df39..db63914 100644
--- a/net/mac802154/tx.c
+++ b/net/mac802154/tx.c
@@ -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;
diff --git a/net/mac802154/wpan.c b/net/mac802154/wpan.c
index f30f6d4..1191039 100644
--- a/net/mac802154/wpan.c
+++ b/net/mac802154/wpan.c
@@ -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++;
--
1.7.11.2


2012-11-30 04:25:31

by Alan Ott

[permalink] [raw]
Subject: [PATCH 2/2] mac802154: use kfree_skb() instead of dev_kfree_skb()

kfree_skb() indicates failure, which is where this is being used.

Signed-off-by: Alan Ott <[email protected]>
---
net/mac802154/tx.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/mac802154/tx.c b/net/mac802154/tx.c
index db63914..4e09d07 100644
--- a/net/mac802154/tx.c
+++ b/net/mac802154/tx.c
@@ -99,7 +99,7 @@ netdev_tx_t mac802154_tx(struct mac802154_priv *priv, struct sk_buff *skb,
}

if (skb_cow_head(skb, priv->hw.extra_tx_headroom)) {
- dev_kfree_skb(skb);
+ kfree_skb(skb);
return NETDEV_TX_OK;
}

--
1.7.11.2

2012-11-30 17:19:50

by David Miller

[permalink] [raw]
Subject: Re: [PATCH 1/2] mac802154: fix memory leaks

From: Alan Ott <[email protected]>
Date: Thu, 29 Nov 2012 23:25:10 -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 <[email protected]>

Applied.

2012-11-30 17:19:54

by David Miller

[permalink] [raw]
Subject: Re: [PATCH 2/2] mac802154: use kfree_skb() instead of dev_kfree_skb()

From: Alan Ott <[email protected]>
Date: Thu, 29 Nov 2012 23:25:11 -0500

> kfree_skb() indicates failure, which is where this is being used.
>
> Signed-off-by: Alan Ott <[email protected]>

Applied.