From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B076C3DB8F for ; Wed, 15 Nov 2023 20:03:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="RHLwVpte" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 55F92C433C8; Wed, 15 Nov 2023 20:03:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1700078625; bh=BvjPBTeF35/wKnGGrgt/BEocDym2Hsywg0ICByjTePM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RHLwVpte8FypleDp3YsZaUFmyqU77wArbTsg352K+I5qulArxEQTnoq8kjSZZghOg XnSZt5CY1Rj0p0VvhDWXa1BnEpPNUG+TG5bHOCblCwngbUMDomkW6oF1zYbe55oAbn UVWkefZqe5OX4VIuHzHvLr3gr4EBAr5b9qj1W7Oc= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Andrii Staikov , Aleksandr Loktionov , Simon Horman , Tony Nguyen , Sasha Levin Subject: [PATCH 4.14 01/45] i40e: fix potential memory leaks in i40e_remove() Date: Wed, 15 Nov 2023 14:32:38 -0500 Message-ID: <20231115191419.749189060@linuxfoundation.org> X-Mailer: git-send-email 2.42.1 In-Reply-To: <20231115191419.641552204@linuxfoundation.org> References: <20231115191419.641552204@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Andrii Staikov [ 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: 41c445ff0f48 ("i40e: main driver core") Signed-off-by: Andrii Staikov Signed-off-by: Aleksandr Loktionov Reviewed-by: Simon Horman Signed-off-by: Tony Nguyen Signed-off-by: Sasha Levin --- drivers/net/ethernet/intel/i40e/i40e_main.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/intel/i40e/i40e_main.c b/drivers/net/ethernet/intel/i40e/i40e_main.c index 50aa53988b483..a7bcdf7c6686c 100644 --- a/drivers/net/ethernet/intel/i40e/i40e_main.c +++ b/drivers/net/ethernet/intel/i40e/i40e_main.c @@ -11882,11 +11882,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; + } /* remove attached clients */ if (pf->flags & I40E_FLAG_IWARP_ENABLED) { -- 2.42.0