Skip to content

Commit

Permalink
e1000: ring buffers resources cleanup
Browse files Browse the repository at this point in the history
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>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Auke Kok <auke-jan.h.kok@intel.com>
  • Loading branch information
Vasily Averin authored and Auke Kok committed Aug 28, 2006
1 parent 6dd62ab commit 3fbbc72
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions drivers/net/e1000/e1000_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -1395,10 +1395,6 @@ e1000_setup_tx_resources(struct e1000_adapter *adapter,
* (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
**/

Expand All @@ -1412,6 +1408,9 @@ e1000_setup_all_tx_resources(struct e1000_adapter *adapter)
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;
}
}
Expand Down Expand Up @@ -1651,10 +1650,6 @@ e1000_setup_rx_resources(struct e1000_adapter *adapter,
* (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
**/

Expand All @@ -1668,6 +1663,9 @@ e1000_setup_all_rx_resources(struct e1000_adapter *adapter)
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;
}
}
Expand Down

0 comments on commit 3fbbc72

Please sign in to comment.