mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-11-01 17:08:10 +00:00
igbvf: fix memory leak when ring size changed while interface down
This patch resolves a memory leak which occurs while changing the ring size while the interface is down. Signed-off-by: Alexander Duyck <alexander.h.duyck@intel.com> Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
759884b4d4
commit
39305965f3
1 changed files with 17 additions and 13 deletions
|
@ -279,7 +279,7 @@ static int igbvf_set_ringparam(struct net_device *netdev,
|
||||||
{
|
{
|
||||||
struct igbvf_adapter *adapter = netdev_priv(netdev);
|
struct igbvf_adapter *adapter = netdev_priv(netdev);
|
||||||
struct igbvf_ring *temp_ring;
|
struct igbvf_ring *temp_ring;
|
||||||
int err;
|
int err = 0;
|
||||||
u32 new_rx_count, new_tx_count;
|
u32 new_rx_count, new_tx_count;
|
||||||
|
|
||||||
if ((ring->rx_mini_pending) || (ring->rx_jumbo_pending))
|
if ((ring->rx_mini_pending) || (ring->rx_jumbo_pending))
|
||||||
|
@ -299,14 +299,21 @@ static int igbvf_set_ringparam(struct net_device *netdev,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
temp_ring = vmalloc(sizeof(struct igbvf_ring));
|
|
||||||
if (!temp_ring)
|
|
||||||
return -ENOMEM;
|
|
||||||
|
|
||||||
while (test_and_set_bit(__IGBVF_RESETTING, &adapter->state))
|
while (test_and_set_bit(__IGBVF_RESETTING, &adapter->state))
|
||||||
msleep(1);
|
msleep(1);
|
||||||
|
|
||||||
if (netif_running(adapter->netdev))
|
if (!netif_running(adapter->netdev)) {
|
||||||
|
adapter->tx_ring->count = new_tx_count;
|
||||||
|
adapter->rx_ring->count = new_rx_count;
|
||||||
|
goto clear_reset;
|
||||||
|
}
|
||||||
|
|
||||||
|
temp_ring = vmalloc(sizeof(struct igbvf_ring));
|
||||||
|
if (!temp_ring) {
|
||||||
|
err = -ENOMEM;
|
||||||
|
goto clear_reset;
|
||||||
|
}
|
||||||
|
|
||||||
igbvf_down(adapter);
|
igbvf_down(adapter);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -339,14 +346,11 @@ static int igbvf_set_ringparam(struct net_device *netdev,
|
||||||
|
|
||||||
memcpy(adapter->rx_ring, temp_ring,sizeof(struct igbvf_ring));
|
memcpy(adapter->rx_ring, temp_ring,sizeof(struct igbvf_ring));
|
||||||
}
|
}
|
||||||
|
|
||||||
err = 0;
|
|
||||||
err_setup:
|
err_setup:
|
||||||
if (netif_running(adapter->netdev))
|
|
||||||
igbvf_up(adapter);
|
igbvf_up(adapter);
|
||||||
|
|
||||||
clear_bit(__IGBVF_RESETTING, &adapter->state);
|
|
||||||
vfree(temp_ring);
|
vfree(temp_ring);
|
||||||
|
clear_reset:
|
||||||
|
clear_bit(__IGBVF_RESETTING, &adapter->state);
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue