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

Commit 25eaef1d authored by Andrii Staikov's avatar Andrii Staikov Committed by Greg Kroah-Hartman
Browse files

i40e: fix potential memory leaks in i40e_remove()



[ Upstream commit 5ca636d927a106780451d957734f02589b972e2b ]

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
number equal to the number of allocated VSIs.

Fixes: 41c445ff ("i40e: main driver core")
Signed-off-by: default avatarAndrii Staikov <andrii.staikov@intel.com>
Signed-off-by: default avatarAleksandr Loktionov <aleksandr.loktionov@intel.com>
Reviewed-by: default avatarSimon Horman <horms@kernel.org>
Signed-off-by: default avatarTony Nguyen <anthony.l.nguyen@intel.com>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
parent 09ce728c
Loading
Loading
Loading
Loading
+7 −3
Original line number Diff line number Diff line
@@ -15553,11 +15553,15 @@ static void i40e_remove(struct pci_dev *pdev)
			i40e_switch_branch_release(pf->veb[i]);
	}

	/* Now we can shutdown the PF's VSI, just before we kill
	/* Now we can shutdown the PF's VSIs, 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_release(pf->vsi[i]);
			pf->vsi[i] = NULL;
		}

	i40e_cloud_filter_exit(pf);