aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Duyck <alexander.h.duyck@intel.com>2012-05-05 01:32:26 -0400
committerJeff Kirsher <jeffrey.t.kirsher@intel.com>2012-07-19 21:13:07 -0400
commitd773d1310625be3b040b436178ad59a0af8888f1 (patch)
tree22934aa31e7a717ce00bfa6e8d5e9b46310f5425
parent1d9c0bfd0f0470c8fb0033999f623d4eec7b1a2c (diff)
ixgbe: Fix memory leak when SR-IOV VFs are direct assigned
The VF driver had a memory leak that would occur if VFs were assigned to a guest. The amount of leak would vary with the number of VFs but could max out at about 14K per PF. To reproduce the leak all you would need to do is enable all the VFs on the first PF. Then start a loop of loading and unloading the driver with max_vfs=63 for the first port. Signed-off-by: Alexander Duyck <alexander.h.duyck@intel.com> Tested-by: Phil Schmitt <phillip.j.schmitt@intel.com> Tested-by: Sibai Li <sibai.li@intel.com> Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
-rw-r--r--drivers/net/ethernet/intel/ixgbe/ixgbe_sriov.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_sriov.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_sriov.c
index c7d831d6e212..4f22668b6aea 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_sriov.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_sriov.c
@@ -208,6 +208,17 @@ void ixgbe_disable_sriov(struct ixgbe_adapter *adapter)
208 u32 vmdctl; 208 u32 vmdctl;
209 int i; 209 int i;
210 210
211 /* set num VFs to 0 to prevent access to vfinfo */
212 adapter->num_vfs = 0;
213
214 /* free VF control structures */
215 kfree(adapter->vfinfo);
216 adapter->vfinfo = NULL;
217
218 /* free macvlan list */
219 kfree(adapter->mv_list);
220 adapter->mv_list = NULL;
221
211#ifdef CONFIG_PCI_IOV 222#ifdef CONFIG_PCI_IOV
212 /* disable iov and allow time for transactions to clear */ 223 /* disable iov and allow time for transactions to clear */
213 pci_disable_sriov(adapter->pdev); 224 pci_disable_sriov(adapter->pdev);
@@ -238,11 +249,7 @@ void ixgbe_disable_sriov(struct ixgbe_adapter *adapter)
238 if (adapter->vfinfo[i].vfdev) 249 if (adapter->vfinfo[i].vfdev)
239 pci_dev_put(adapter->vfinfo[i].vfdev); 250 pci_dev_put(adapter->vfinfo[i].vfdev);
240 } 251 }
241 kfree(adapter->vfinfo);
242 kfree(adapter->mv_list);
243 adapter->vfinfo = NULL;
244 252
245 adapter->num_vfs = 0;
246 adapter->flags &= ~IXGBE_FLAG_SRIOV_ENABLED; 253 adapter->flags &= ~IXGBE_FLAG_SRIOV_ENABLED;
247} 254}
248 255