i40e: fix potential memory leaks in i40e_remove()
Subsystems (2)
PATCH v2 1/1 i40e: fix potential memory leaks in i40e_remove()
Instead of freeing memory of a single VSI, make sure the memory for all VSIs is cleared before releasing VSIs. Add releasing of their resources in a loop with the iteration mumber equal to the number of allocated VSIs.
---
v1 -> v2: Changed commit message.
--- drivers/net/ethernet/intel/i40e/i40e_main.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
drivers/net/ethernet/intel/i40e/i40e_main.c +8 -2
@@ -16326,8 +16326,14 @@ static void i40e_remove(struct pci_dev *pdev)/* Now we can shutdown the PF's VSI, just before we kill * adminq and hmc. */ -if (pf->vsi[pf->lan_vsi]) -i40e_vsi_release (pf->vsi[pf->lan_vsi]); +for (i = pf->num_alloc_vsi; i--;) +if (pf->vsi[i]) { +i40e_vsi_close (pf->vsi[i]); +i40e_vsi_free_q_vectors (pf->vsi[i]); +i40e_vsi_release (pf->vsi[i]); +kfree (pf->vsi[i]); + pf->vsi[i] =NULL ; + }i40e_cloud_filter_exit (pf);
Signature · 6 lines
2.25.1 _______________________________________________ Intel-wired-lan mailing list [email protected] https://lists.osuosl.org/mailman/listinfo/intel-wired-lan
Tony Nguyen
maintainerQuoted 4 lines · Andrii Staikov
Instead of freeing memory of a single VSI, make sure the memory for all VSIs is cleared before releasing VSIs. Add releasing of their resources in a loop with the iteration mumber equal to the number of allocated VSIs.
WARNING: 'mumber' may be misspelled - perhaps 'number'?
Quoted 21 lines
Fixes 41c445ff0f48 ("i40e: main driver core")Signed-off-by Andrii Staikov <[email protected]>Signed-off-by Aleksandr Loktionov <[email protected]>---
v1 -> v2: Changed commit message.--- drivers/net/ethernet/intel/i40e/i40e_main.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)drivers/net/ethernet/intel/i40e/i40e_main.c +1
-2@@ -16326,8 +16326,14 @@ static void i40e_remove(struct pci_dev *pdev)/* Now we can shutdown the PF's VSI, just before we kill * adminq and hmc. */ -if (pf->vsi[pf->lan_vsi]) -i40e_vsi_release (pf->vsi[pf->lan_vsi]); +for (i = pf->num_alloc_vsi; i--;)
drivers/net/ethernet/intel/i40e/i40e_main.c static void i40e_remove(struct pci_dev *pdev) · line 16339
Quoted 10 lines
drivers/net/ethernet/intel/i40e/i40e_main.c +7
-0+if (pf->vsi[i]) { +i40e_vsi_close (pf->vsi[i]); +i40e_vsi_free_q_vectors (pf->vsi[i]); +i40e_vsi_release (pf->vsi[i]); +kfree (pf->vsi[i]); + pf->vsi[i] =NULL ; + }i40e_cloud_filter_exit (pf);
_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan