提交 8472ba62 编写于 作者: W Wenwen Wang 提交者: Jeff Kirsher

e1000: fix memory leaks

In e1000_set_ringparam(), 'tx_old' and 'rx_old' are not deallocated if
e1000_up() fails, leading to memory leaks. Refactor the code to fix this
issue.
Signed-off-by: NWenwen Wang <wenwen@cs.uga.edu>
Tested-by: NAaron Brown <aaron.f.brown@intel.com>
Signed-off-by: NJeff Kirsher <jeffrey.t.kirsher@intel.com>
上级 2c19e395
...@@ -607,6 +607,7 @@ static int e1000_set_ringparam(struct net_device *netdev, ...@@ -607,6 +607,7 @@ static int e1000_set_ringparam(struct net_device *netdev,
for (i = 0; i < adapter->num_rx_queues; i++) for (i = 0; i < adapter->num_rx_queues; i++)
rxdr[i].count = rxdr->count; rxdr[i].count = rxdr->count;
err = 0;
if (netif_running(adapter->netdev)) { if (netif_running(adapter->netdev)) {
/* Try to get new resources before deleting old */ /* Try to get new resources before deleting old */
err = e1000_setup_all_rx_resources(adapter); err = e1000_setup_all_rx_resources(adapter);
...@@ -627,14 +628,13 @@ static int e1000_set_ringparam(struct net_device *netdev, ...@@ -627,14 +628,13 @@ static int e1000_set_ringparam(struct net_device *netdev,
adapter->rx_ring = rxdr; adapter->rx_ring = rxdr;
adapter->tx_ring = txdr; adapter->tx_ring = txdr;
err = e1000_up(adapter); err = e1000_up(adapter);
if (err)
goto err_setup;
} }
kfree(tx_old); kfree(tx_old);
kfree(rx_old); kfree(rx_old);
clear_bit(__E1000_RESETTING, &adapter->flags); clear_bit(__E1000_RESETTING, &adapter->flags);
return 0; return err;
err_setup_tx: err_setup_tx:
e1000_free_all_rx_resources(adapter); e1000_free_all_rx_resources(adapter);
err_setup_rx: err_setup_rx:
...@@ -646,7 +646,6 @@ static int e1000_set_ringparam(struct net_device *netdev, ...@@ -646,7 +646,6 @@ static int e1000_set_ringparam(struct net_device *netdev,
err_alloc_tx: err_alloc_tx:
if (netif_running(adapter->netdev)) if (netif_running(adapter->netdev))
e1000_up(adapter); e1000_up(adapter);
err_setup:
clear_bit(__E1000_RESETTING, &adapter->flags); clear_bit(__E1000_RESETTING, &adapter->flags);
return err; return err;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册