netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ath9k: fix a memory leak in ath_rx_tasklet()
@ 2012-03-15 20:43 Eric Dumazet
  2012-03-16 14:00 ` John W. Linville
  0 siblings, 1 reply; 3+ messages in thread
From: Eric Dumazet @ 2012-03-15 20:43 UTC (permalink / raw)
  To: John W. Linville, David Miller
  Cc: Jouni Malinen, Felix Fietkau, Trond Wuellner, Grant Grundler,
	Paul Stewart, netdev

commit 0d95521ea7 (ath9k: use split rx buffers to get rid of order-1 skb
allocations) added in memory leak in error path.

sc->rx.frag should be cleared after the pskb_expand_head() call, or else
we jump to requeue_drop_frag and leak an skb.

Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
Cc: Jouni Malinen <jouni@qca.qualcomm.com>
Cc: Felix Fietkau <nbd@openwrt.org>
Cc: John W. Linville <linville@tuxdriver.com>
Cc: Trond Wuellner <trond@chromium.org>
Cc: Grant Grundler <grundler@chromium.org>
Cc: Paul Stewart <pstew@chromium.org>
Cc: David Miller <davem@davemloft.net>
---
 drivers/net/wireless/ath/ath9k/recv.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/wireless/ath/ath9k/recv.c b/drivers/net/wireless/ath/ath9k/recv.c
index 7e1a91a..e74fc99 100644
--- a/drivers/net/wireless/ath/ath9k/recv.c
+++ b/drivers/net/wireless/ath/ath9k/recv.c
@@ -1917,13 +1917,13 @@ int ath_rx_tasklet(struct ath_softc *sc, int flush, bool hp)
 		if (sc->rx.frag) {
 			int space = skb->len - skb_tailroom(hdr_skb);
 
-			sc->rx.frag = NULL;
-
 			if (pskb_expand_head(hdr_skb, 0, space, GFP_ATOMIC) < 0) {
 				dev_kfree_skb(skb);
 				goto requeue_drop_frag;
 			}
 
+			sc->rx.frag = NULL;
+
 			skb_copy_from_linear_data(skb, skb_put(hdr_skb, skb->len),
 						  skb->len);
 			dev_kfree_skb_any(skb);

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] ath9k: fix a memory leak in ath_rx_tasklet()
  2012-03-15 20:43 [PATCH] ath9k: fix a memory leak in ath_rx_tasklet() Eric Dumazet
@ 2012-03-16 14:00 ` John W. Linville
  2012-03-21 10:21   ` Eric Dumazet
  0 siblings, 1 reply; 3+ messages in thread
From: John W. Linville @ 2012-03-16 14:00 UTC (permalink / raw)
  To: Eric Dumazet
  Cc: David Miller, Jouni Malinen, Felix Fietkau, Trond Wuellner,
	Grant Grundler, Paul Stewart, netdev

On Thu, Mar 15, 2012 at 01:43:29PM -0700, Eric Dumazet wrote:
> commit 0d95521ea7 (ath9k: use split rx buffers to get rid of order-1 skb
> allocations) added in memory leak in error path.
> 
> sc->rx.frag should be cleared after the pskb_expand_head() call, or else
> we jump to requeue_drop_frag and leak an skb.
> 
> Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
> Cc: Jouni Malinen <jouni@qca.qualcomm.com>
> Cc: Felix Fietkau <nbd@openwrt.org>
> Cc: John W. Linville <linville@tuxdriver.com>
> Cc: Trond Wuellner <trond@chromium.org>
> Cc: Grant Grundler <grundler@chromium.org>
> Cc: Paul Stewart <pstew@chromium.org>
> Cc: David Miller <davem@davemloft.net>

Acked-by: John W. Linville <linville@tuxdriver.com>

Dave, will you pick this up yourself?  Or should I take it around the bend?

John

> ---
>  drivers/net/wireless/ath/ath9k/recv.c |    4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/net/wireless/ath/ath9k/recv.c b/drivers/net/wireless/ath/ath9k/recv.c
> index 7e1a91a..e74fc99 100644
> --- a/drivers/net/wireless/ath/ath9k/recv.c
> +++ b/drivers/net/wireless/ath/ath9k/recv.c
> @@ -1917,13 +1917,13 @@ int ath_rx_tasklet(struct ath_softc *sc, int flush, bool hp)
>  		if (sc->rx.frag) {
>  			int space = skb->len - skb_tailroom(hdr_skb);
>  
> -			sc->rx.frag = NULL;
> -
>  			if (pskb_expand_head(hdr_skb, 0, space, GFP_ATOMIC) < 0) {
>  				dev_kfree_skb(skb);
>  				goto requeue_drop_frag;
>  			}
>  
> +			sc->rx.frag = NULL;
> +
>  			skb_copy_from_linear_data(skb, skb_put(hdr_skb, skb->len),
>  						  skb->len);
>  			dev_kfree_skb_any(skb);
> 
> 
> 

-- 
John W. Linville		Someday the world will need a hero, and you
linville@tuxdriver.com			might be all we have.  Be ready.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] ath9k: fix a memory leak in ath_rx_tasklet()
  2012-03-16 14:00 ` John W. Linville
@ 2012-03-21 10:21   ` Eric Dumazet
  0 siblings, 0 replies; 3+ messages in thread
From: Eric Dumazet @ 2012-03-21 10:21 UTC (permalink / raw)
  To: John W. Linville
  Cc: David Miller, Jouni Malinen, Felix Fietkau, Trond Wuellner,
	Grant Grundler, Paul Stewart, netdev

Le vendredi 16 mars 2012 à 10:00 -0400, John W. Linville a écrit :
> On Thu, Mar 15, 2012 at 01:43:29PM -0700, Eric Dumazet wrote:
> > commit 0d95521ea7 (ath9k: use split rx buffers to get rid of order-1 skb
> > allocations) added in memory leak in error path.
> > 
> > sc->rx.frag should be cleared after the pskb_expand_head() call, or else
> > we jump to requeue_drop_frag and leak an skb.
> > 
> > Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
> > Cc: Jouni Malinen <jouni@qca.qualcomm.com>
> > Cc: Felix Fietkau <nbd@openwrt.org>
> > Cc: John W. Linville <linville@tuxdriver.com>
> > Cc: Trond Wuellner <trond@chromium.org>
> > Cc: Grant Grundler <grundler@chromium.org>
> > Cc: Paul Stewart <pstew@chromium.org>
> > Cc: David Miller <davem@davemloft.net>
> 
> Acked-by: John W. Linville <linville@tuxdriver.com>
> 
> Dave, will you pick this up yourself?  Or should I take it around the bend?

I dont know, please make sure its not lost anyway :

I have an upcoming patch on top on this one to reduce ath9k skb truesize
by 50% and get better tcp receives.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2012-03-21 10:21 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-03-15 20:43 [PATCH] ath9k: fix a memory leak in ath_rx_tasklet() Eric Dumazet
2012-03-16 14:00 ` John W. Linville
2012-03-21 10:21   ` Eric Dumazet

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).