* [PATCH] e1000: ring buffers resources cleanup
@ 2006-08-18 15:02 Vasily Averin
[not found] ` <1155917427.24835.57.camel@localhost>
0 siblings, 1 reply; 3+ messages in thread
From: Vasily Averin @ 2006-08-18 15:02 UTC (permalink / raw)
To: netdev, Jeb Cramer, John Ronciak, Jesse Brandeburg, Jeff Kirsher,
Auke Kok, Andrew Morton, Jeff Garzik, devel, e1000-devel
[-- Attachment #1: Type: text/plain, Size: 267 bytes --]
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.
Signed-off-by: Vasily Averin <vvs@sw.ru>
Thank you,
Vasily Averin
SWsoft Virtuozzo/OpenVZ Linux kernel team
[-- Attachment #2: diff-e1000-ringresources-20060818 --]
[-- Type: text/plain, Size: 714 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-18 18:53:05.000000000 +0400
@@ -1398,6 +1398,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;
}
}
@@ -1656,6 +1659,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;
}
}
[-- Attachment #3: Type: text/plain, Size: 373 bytes --]
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
[-- Attachment #4: Type: text/plain, Size: 164 bytes --]
_______________________________________________
E1000-devel mailing list
E1000-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/e1000-devel
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH] e1000: ring buffers resources cleanup
@ 2006-08-18 15:23 Vasily Averin
0 siblings, 0 replies; 3+ messages in thread
From: Vasily Averin @ 2006-08-18 15:23 UTC (permalink / raw)
To: netdev, Jeb Cramer, John Ronciak, Jesse Brandeburg, Jeff Kirsher,
Auke Kok, Andrew Morton, Jeff Garzik, devel, e1000-devel
[-- Attachment #1: Type: text/plain, Size: 241 bytes --]
irq leak was found in 2.6.18-rc4 and e1000 7.2.7 from sourceforge:
if e1000_up fails in e1000_open() we do not free allocated irq
Signed-off-by: Vasily Averin <vvs@sw.ru>
Thank you,
Vasily Averin
SWsoft Virtuozzo/OpenVZ Linux kernel team
[-- Attachment #2: diff-e1000-irqleak-20060818 --]
[-- Type: text/plain, Size: 593 bytes --]
--- linux-2.6.18-rc4/drivers/net/e1000/e1000_main.c.oirq 2006-08-18 18:53:05.000000000 +0400
+++ linux-2.6.18-rc4/drivers/net/e1000/e1000_main.c 2006-08-18 19:18:22.000000000 +0400
@@ -1208,7 +1208,7 @@ e1000_open(struct net_device *netdev)
err = e1000_request_irq(adapter);
if (err)
- goto err_up;
+ goto err_req_irq;
e1000_power_up_phy(adapter);
@@ -1229,6 +1229,8 @@ e1000_open(struct net_device *netdev)
return E1000_SUCCESS;
err_up:
+ e1000_free_irq(adapter);
+err_req_irq:
e1000_free_all_rx_resources(adapter);
err_setup_rx:
e1000_free_all_tx_resources(adapter);
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] e1000: ring buffers resources cleanup
[not found] ` <1155917427.24835.57.camel@localhost>
@ 2006-08-19 20:14 ` Vasily Averin
0 siblings, 0 replies; 3+ messages in thread
From: Vasily Averin @ 2006-08-19 20:14 UTC (permalink / raw)
To: Joe Perches, netdev, Jeb Cramer, John Ronciak, Jesse Brandeburg,
Jeff Kirsher, Auke Kok, Andrew Morton, Jeff Garzik, devel,
e1000-devel
[-- 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;
}
}
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2006-08-19 20:14 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
-- strict thread matches above, loose matches on Subject: below --
2006-08-18 15:23 Vasily Averin
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).