netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] gianfar: Fix a memory leak in gianfar close code
@ 2010-03-30  1:42 Andy Fleming
  2010-03-30 16:50 ` Laurent Chavey
  2010-03-31  6:09 ` David Miller
  0 siblings, 2 replies; 3+ messages in thread
From: Andy Fleming @ 2010-03-30  1:42 UTC (permalink / raw)
  To: davem; +Cc: netdev, eric.dumazet, Sandeep.Kumar

gianfar needed to ensure existence of the *skbuff arrays before
freeing the skbs in them, rather than ensuring their nonexistence.

Signed-off-by: Andy Fleming <afleming@freescale.com>
---
 drivers/net/gianfar.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/gianfar.c b/drivers/net/gianfar.c
index b671555..ad59608 100644
--- a/drivers/net/gianfar.c
+++ b/drivers/net/gianfar.c
@@ -1638,13 +1638,13 @@ static void free_skb_resources(struct gfar_private *priv)
 	/* Go through all the buffer descriptors and free their data buffers */
 	for (i = 0; i < priv->num_tx_queues; i++) {
 		tx_queue = priv->tx_queue[i];
-		if(!tx_queue->tx_skbuff)
+		if(tx_queue->tx_skbuff)
 			free_skb_tx_queue(tx_queue);
 	}
 
 	for (i = 0; i < priv->num_rx_queues; i++) {
 		rx_queue = priv->rx_queue[i];
-		if(!rx_queue->rx_skbuff)
+		if(rx_queue->rx_skbuff)
 			free_skb_rx_queue(rx_queue);
 	}
 
-- 
1.6.5.2.g6ff9a


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

* Re: [PATCH] gianfar: Fix a memory leak in gianfar close code
  2010-03-30  1:42 [PATCH] gianfar: Fix a memory leak in gianfar close code Andy Fleming
@ 2010-03-30 16:50 ` Laurent Chavey
  2010-03-31  6:09 ` David Miller
  1 sibling, 0 replies; 3+ messages in thread
From: Laurent Chavey @ 2010-03-30 16:50 UTC (permalink / raw)
  To: Andy Fleming; +Cc: davem, netdev, eric.dumazet, Sandeep.Kumar

since free_skb_[rx | tx]_queue() expects rx_queue->rx_skbuff to not be NULL
what about moving the conditional if(rx_queue->rx_skbuff)
in free_skb_rx_queue() and  if(tx_queue->tx_skbuff) in free_skb_tx_queue()
OR put an assertion for not NULL in those functions ?



On Mon, Mar 29, 2010 at 6:42 PM, Andy Fleming <afleming@freescale.com> wrote:
> gianfar needed to ensure existence of the *skbuff arrays before
> freeing the skbs in them, rather than ensuring their nonexistence.
>
> Signed-off-by: Andy Fleming <afleming@freescale.com>
> ---
>  drivers/net/gianfar.c |    4 ++--
>  1 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/net/gianfar.c b/drivers/net/gianfar.c
> index b671555..ad59608 100644
> --- a/drivers/net/gianfar.c
> +++ b/drivers/net/gianfar.c
> @@ -1638,13 +1638,13 @@ static void free_skb_resources(struct gfar_private *priv)
>        /* Go through all the buffer descriptors and free their data buffers */
>        for (i = 0; i < priv->num_tx_queues; i++) {
>                tx_queue = priv->tx_queue[i];
> -               if(!tx_queue->tx_skbuff)
> +               if(tx_queue->tx_skbuff)
>                        free_skb_tx_queue(tx_queue);
>        }
>
>        for (i = 0; i < priv->num_rx_queues; i++) {
>                rx_queue = priv->rx_queue[i];
> -               if(!rx_queue->rx_skbuff)
> +               if(rx_queue->rx_skbuff)
>                        free_skb_rx_queue(rx_queue);
>        }
>
> --
> 1.6.5.2.g6ff9a
>
> --
> To unsubscribe from this list: send the line "unsubscribe netdev" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>

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

* Re: [PATCH] gianfar: Fix a memory leak in gianfar close code
  2010-03-30  1:42 [PATCH] gianfar: Fix a memory leak in gianfar close code Andy Fleming
  2010-03-30 16:50 ` Laurent Chavey
@ 2010-03-31  6:09 ` David Miller
  1 sibling, 0 replies; 3+ messages in thread
From: David Miller @ 2010-03-31  6:09 UTC (permalink / raw)
  To: afleming; +Cc: netdev, eric.dumazet, Sandeep.Kumar

From: Andy Fleming <afleming@freescale.com>
Date: Mon, 29 Mar 2010 20:42:23 -0500

> gianfar needed to ensure existence of the *skbuff arrays before
> freeing the skbs in them, rather than ensuring their nonexistence.
> 
> Signed-off-by: Andy Fleming <afleming@freescale.com>

Although some refactorings have been suggested, this fixes the bug
straightforwardly and is therefore the most appropriate fix for
net-2.6

Applied, thanks.

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

end of thread, other threads:[~2010-03-31  6:09 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-03-30  1:42 [PATCH] gianfar: Fix a memory leak in gianfar close code Andy Fleming
2010-03-30 16:50 ` Laurent Chavey
2010-03-31  6:09 ` David Miller

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).