Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 759884b4 authored by Alexander Duyck's avatar Alexander Duyck Committed by David S. Miller
Browse files

ixgbe: fix memory leak when resizing rings while interface is down



This patch resolves a memory leak that occurs when you resize the rings via
the ethtool -G option while the interface is down.

Signed-off-by: default avatarAlexander Duyck <alexander.h.duyck@intel.com>
Signed-off-by: default avatarJeff Kirsher <jeffrey.t.kirsher@intel.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 6d9f4fc4
Loading
Loading
Loading
Loading
+13 −9
Original line number Original line Diff line number Diff line
@@ -798,7 +798,7 @@ static int ixgbe_set_ringparam(struct net_device *netdev,
{
{
	struct ixgbe_adapter *adapter = netdev_priv(netdev);
	struct ixgbe_adapter *adapter = netdev_priv(netdev);
	struct ixgbe_ring *temp_tx_ring, *temp_rx_ring;
	struct ixgbe_ring *temp_tx_ring, *temp_rx_ring;
	int i, err;
	int i, err = 0;
	u32 new_rx_count, new_tx_count;
	u32 new_rx_count, new_tx_count;
	bool need_update = false;
	bool need_update = false;


@@ -822,6 +822,16 @@ static int ixgbe_set_ringparam(struct net_device *netdev,
	while (test_and_set_bit(__IXGBE_RESETTING, &adapter->state))
	while (test_and_set_bit(__IXGBE_RESETTING, &adapter->state))
		msleep(1);
		msleep(1);


	if (!netif_running(adapter->netdev)) {
		for (i = 0; i < adapter->num_tx_queues; i++)
			adapter->tx_ring[i].count = new_tx_count;
		for (i = 0; i < adapter->num_rx_queues; i++)
			adapter->rx_ring[i].count = new_rx_count;
		adapter->tx_ring_count = new_tx_count;
		adapter->rx_ring_count = new_rx_count;
		goto err_setup;
	}

	temp_tx_ring = kcalloc(adapter->num_tx_queues,
	temp_tx_ring = kcalloc(adapter->num_tx_queues,
	                       sizeof(struct ixgbe_ring), GFP_KERNEL);
	                       sizeof(struct ixgbe_ring), GFP_KERNEL);
	if (!temp_tx_ring) {
	if (!temp_tx_ring) {
@@ -879,7 +889,6 @@ static int ixgbe_set_ringparam(struct net_device *netdev,


	/* if rings need to be updated, here's the place to do it in one shot */
	/* if rings need to be updated, here's the place to do it in one shot */
	if (need_update) {
	if (need_update) {
		if (netif_running(netdev))
		ixgbe_down(adapter);
		ixgbe_down(adapter);


		/* tx */
		/* tx */
@@ -897,13 +906,8 @@ static int ixgbe_set_ringparam(struct net_device *netdev,
			temp_rx_ring = NULL;
			temp_rx_ring = NULL;
			adapter->rx_ring_count = new_rx_count;
			adapter->rx_ring_count = new_rx_count;
		}
		}
	}

	/* success! */
	err = 0;
	if (netif_running(netdev))
		ixgbe_up(adapter);
		ixgbe_up(adapter);

	}
err_setup:
err_setup:
	clear_bit(__IXGBE_RESETTING, &adapter->state);
	clear_bit(__IXGBE_RESETTING, &adapter->state);
	return err;
	return err;