Skip to content

Commit d773d13

Browse files
Alexander DuyckJeff Kirsher
authored andcommitted
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 <[email protected]> Tested-by: Phil Schmitt <[email protected]> Tested-by: Sibai Li <[email protected]> Signed-off-by: Jeff Kirsher <[email protected]>
1 parent 1d9c0bf commit d773d13

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

drivers/net/ethernet/intel/ixgbe/ixgbe_sriov.c

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,17 @@ void ixgbe_disable_sriov(struct ixgbe_adapter *adapter)
208208
u32 vmdctl;
209209
int i;
210210

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+
211222
#ifdef CONFIG_PCI_IOV
212223
/* disable iov and allow time for transactions to clear */
213224
pci_disable_sriov(adapter->pdev);
@@ -238,11 +249,7 @@ void ixgbe_disable_sriov(struct ixgbe_adapter *adapter)
238249
if (adapter->vfinfo[i].vfdev)
239250
pci_dev_put(adapter->vfinfo[i].vfdev);
240251
}
241-
kfree(adapter->vfinfo);
242-
kfree(adapter->mv_list);
243-
adapter->vfinfo = NULL;
244252

245-
adapter->num_vfs = 0;
246253
adapter->flags &= ~IXGBE_FLAG_SRIOV_ENABLED;
247254
}
248255

0 commit comments

Comments
 (0)