netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Vasily Averin <vvs@sw.ru>
To: Joe Perches <joe@perches.com>,
	netdev@vger.kernel.org, Jeb Cramer <cramerj@intel.com>,
	John Ronciak <john.ronciak@intel.com>,
	Jesse Brandeburg <jesse.brandeburg@intel.com>,
	Jeff Kirsher <jeffrey.t.kirsher@intel.com>,
	Auke Kok <auke-jan.h.kok@intel.com>,
	Andrew Morton <akpm@osdl.org>, Jeff Garzik <jgarzik@pobox.com>,
	devel@openvz.org, e1000-devel@lists.sourceforge.net
Subject: Re: [PATCH] e1000: ring buffers resources cleanup
Date: Sun, 20 Aug 2006 00:14:09 +0400	[thread overview]
Message-ID: <44E77111.60103@sw.ru> (raw)
In-Reply-To: <1155917427.24835.57.camel@localhost>

[-- Attachment #1: Type: text/plain, Size: 1404 bytes --]

Hello Joe,

Joe Perches wrote:
> On Fri, 2006-08-18 at 19:02 +0400, Vasily Averin wrote:
>>Memory leak was found in 2.6.18-rc4 and e1000 7.2.7 from sourceforge:
>>We should free resources allocated for previous rings if following allocation fails.
> 
> Did you read the comment headers in the function?
> 
>  * If this function returns with an error, then it's possible one or
>  * more of the rings is populated (while the rest are not).  It is the
>  * callers duty to clean those orphaned rings.

Thank you for your notice.
I believe this comment is incorrect: if some function returns an error it should
restore original state on exit, otherwise can lead to resource leaks. Also I
would note that this requirements is not accomplished in current driver version:
e1000_setup_all_Xx_resources functions are called in two places: in
e1000_set_ringparam() and in e1000_open() and in both cases nobody cleans those
orphaned rings.

Therefore I think it make sense to remove these comments too.

Andrew, could you please use attached patch instead previous version?
---
Memory leak was found in 2.6.18-rc4 and e1000 7.2.7 from sourceforge:
We should free resources allocated for previous rings if following allocation
fails. Also incorrect comments in e1000_setup_all_Xx_resources() are removed

Signed-off-by: Vasily Averin <vvs@sw.ru>

Thank you,
	Vasily Averin
SWsoft Virtuozzo/OpenVZ Linux kernel team

[-- Attachment #2: diff-e1000-ringresources-20060819 --]
[-- Type: text/plain, Size: 1454 bytes --]

--- linux-2.6.18-rc4/drivers/net/e1000/e1000_main.c.irsrs	2006-08-18 16:58:51.000000000 +0400
+++ linux-2.6.18-rc4/drivers/net/e1000/e1000_main.c	2006-08-19 22:54:00.000000000 +0400
@@ -1381,10 +1381,6 @@ setup_tx_desc_die:
  * 				  (Descriptors) for all queues
  * @adapter: board private structure
  *
- * If this function returns with an error, then it's possible one or
- * more of the rings is populated (while the rest are not).  It is the
- * callers duty to clean those orphaned rings.
- *
  * Return 0 on success, negative on failure
  **/
 
@@ -1398,6 +1394,9 @@ e1000_setup_all_tx_resources(struct e100
 		if (err) {
 			DPRINTK(PROBE, ERR,
 				"Allocation for Tx Queue %u failed\n", i);
+			for (i-- ; i >= 0; i--)
+				e1000_free_tx_resources(adapter,
+							&adapter->tx_ring[i]);
 			break;
 		}
 	}
@@ -1639,10 +1638,6 @@ setup_rx_desc_die:
  * 				  (Descriptors) for all queues
  * @adapter: board private structure
  *
- * If this function returns with an error, then it's possible one or
- * more of the rings is populated (while the rest are not).  It is the
- * callers duty to clean those orphaned rings.
- *
  * Return 0 on success, negative on failure
  **/
 
@@ -1656,6 +1651,9 @@ e1000_setup_all_rx_resources(struct e100
 		if (err) {
 			DPRINTK(PROBE, ERR,
 				"Allocation for Rx Queue %u failed\n", i);
+			for (i-- ; i >= 0; i--)
+				e1000_free_rx_resources(adapter,
+							&adapter->rx_ring[i]);
 			break;
 		}
 	}

  parent reply	other threads:[~2006-08-19 20:14 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-08-18 15:02 [PATCH] e1000: ring buffers resources cleanup Vasily Averin
     [not found] ` <1155917427.24835.57.camel@localhost>
2006-08-19 20:14   ` Vasily Averin [this message]
  -- strict thread matches above, loose matches on Subject: below --
2006-08-18 15:23 Vasily Averin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=44E77111.60103@sw.ru \
    --to=vvs@sw.ru \
    --cc=akpm@osdl.org \
    --cc=auke-jan.h.kok@intel.com \
    --cc=cramerj@intel.com \
    --cc=devel@openvz.org \
    --cc=e1000-devel@lists.sourceforge.net \
    --cc=jeffrey.t.kirsher@intel.com \
    --cc=jesse.brandeburg@intel.com \
    --cc=jgarzik@pobox.com \
    --cc=joe@perches.com \
    --cc=john.ronciak@intel.com \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).