From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from smtp4.osuosl.org (smtp4.osuosl.org [140.211.166.137]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 5AEB6C352A1 for ; Tue, 6 Dec 2022 10:02:46 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id DDCC0415F1; Tue, 6 Dec 2022 10:02:45 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org DDCC0415F1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=osuosl.org; s=default; t=1670320965; bh=6kZ14D7RzBzX8TS6Ci90n9YEkQQqg/ll4JTZYCxWcuI=; h=Date:From:To:References:In-Reply-To:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: Cc:From; b=FqS9jn4YT3tnSu0/9PrdvupO1e9Bpci3JNP7+79rs2hhG1r+pToXEzBaZ7IPulSEq aCL7bSZ5cPWuFKh2DGnuPRsW879MruNTPfY5dXrv3TrhxZtUbZqNwwUObmHfp5sWVz jcfeZTp8T/JghfIv9krd5IG7h5DjTuGXSkLZ5du2bkM+udSGaSKMoIPSbbWpyw6IrS pzRGkpHOZL8t72XomMoDjFOtDlovgxJxkm/huKIiiXNnV+JjE1r5hziTSl46nTenDr RZ1QUyNcc7y0kYkBm4q+f7Q84vvCzAwhC680W89b5WPK8ICjtyBndKMMObySMjCXoS upv33PMM6qlGg== X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp4.osuosl.org ([127.0.0.1]) by localhost (smtp4.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id KAKEjEmRGnvP; Tue, 6 Dec 2022 10:02:45 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by smtp4.osuosl.org (Postfix) with ESMTP id C5163415F5; Tue, 6 Dec 2022 10:02:44 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org C5163415F5 Received: from smtp1.osuosl.org (smtp1.osuosl.org [140.211.166.138]) by ash.osuosl.org (Postfix) with ESMTP id 2C4ED1BF289 for ; Tue, 6 Dec 2022 10:02:43 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id 1320781329 for ; Tue, 6 Dec 2022 10:02:43 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org 1320781329 X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp1.osuosl.org ([127.0.0.1]) by localhost (smtp1.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id o_eh0tYc3oDa for ; Tue, 6 Dec 2022 10:02:42 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org 446EF81251 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by smtp1.osuosl.org (Postfix) with ESMTPS id 446EF81251 for ; Tue, 6 Dec 2022 10:02:42 +0000 (UTC) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 78485B81690; Tue, 6 Dec 2022 10:02:40 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B6A79C433C1; Tue, 6 Dec 2022 10:02:38 +0000 (UTC) Date: Tue, 6 Dec 2022 12:02:35 +0200 From: Leon Romanovsky To: Yuan Can Message-ID: References: <20221206092613.122952-1-yuancan@huawei.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20221206092613.122952-1-yuancan@huawei.com> X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1670320959; bh=W+U4g9oT9hoz6TyxcYb6WtqTgSP2tm3BeDOnNiaWctw=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Y8uIOsvjzvGdysVIxHgoZY8WSqBlgd7Ug5oGoEdouyeegqJp5Y/uHYC+nVhBs2IV5 V4azNNlOtLf6AlS/SyqVaSVmENRCiNmxuTMNdnF5oGYwNx0tSr9mGAas1dTmn1g7a2 6DX9hJn5zSxWOgPUkjCSGUFm7cBq0Hv87Q4jfnxhPvnv23zD8fdo1RKOro5yURIdUn pAxDUuWtPwxazrksTc4xApsfCibJKvnxWZqGe/hJEGKJA7l9y/H31AxaPG5RCiizy7 MvDFrLa9HBGIRh/O54u+92MB+ZZKjYIzFkoutUdGDulvDm28ei6YO+oxXCjUusl4Qv 2lkyFZWRtKtJg== X-Mailman-Original-Authentication-Results: smtp1.osuosl.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20201202 header.b=Y8uIOsvj Subject: Re: [Intel-wired-lan] [PATCH] intel/i40e: Fix potential memory leak in i40e_init_recovery_mode() X-BeenThere: intel-wired-lan@osuosl.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel Wired Ethernet Linux Kernel Driver Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: intel-wired-lan@lists.osuosl.org, jesse.brandeburg@intel.com, edumazet@google.com, netdev@vger.kernel.org, anthony.l.nguyen@intel.com, jeffrey.t.kirsher@intel.com, piotr.marczak@intel.com, kuba@kernel.org, pabeni@redhat.com, davem@davemloft.net Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: intel-wired-lan-bounces@osuosl.org Sender: "Intel-wired-lan" On Tue, Dec 06, 2022 at 09:26:13AM +0000, Yuan Can wrote: > If i40e_vsi_mem_alloc() failed in i40e_init_recovery_mode(), the pf will be > freed with the pf->vsi leaked. > Fix by free pf->vsi in the error handling path. > > Fixes: 4ff0ee1af016 ("i40e: Introduce recovery mode support") > Signed-off-by: Yuan Can > --- > drivers/net/ethernet/intel/i40e/i40e_main.c | 1 + > 1 file changed, 1 insertion(+) The patch title needs to be "[PATCH net]..." > > diff --git a/drivers/net/ethernet/intel/i40e/i40e_main.c b/drivers/net/ethernet/intel/i40e/i40e_main.c > index b5dcd15ced36..d23081c224d6 100644 > --- a/drivers/net/ethernet/intel/i40e/i40e_main.c > +++ b/drivers/net/ethernet/intel/i40e/i40e_main.c > @@ -15536,6 +15536,7 @@ static int i40e_init_recovery_mode(struct i40e_pf *pf, struct i40e_hw *hw) > pci_disable_pcie_error_reporting(pf->pdev); > pci_release_mem_regions(pf->pdev); > pci_disable_device(pf->pdev); > + kfree(pf->vsi); > kfree(pf); > > return err; The change is ok, but it is worth to cleanup error flow of i40e_probe and i40e_remove as they are not really in the same order. Thanks, Reviewed-by: Leon Romanovsky _______________________________________________ Intel-wired-lan mailing list Intel-wired-lan@osuosl.org https://lists.osuosl.org/mailman/listinfo/intel-wired-lan From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6789DC352A1 for ; Tue, 6 Dec 2022 10:10:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232604AbiLFKKQ (ORCPT ); Tue, 6 Dec 2022 05:10:16 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50702 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231516AbiLFKJy (ORCPT ); Tue, 6 Dec 2022 05:09:54 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 47DB625C4 for ; Tue, 6 Dec 2022 02:02:40 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id D376D612F4 for ; Tue, 6 Dec 2022 10:02:39 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B6A79C433C1; Tue, 6 Dec 2022 10:02:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1670320959; bh=W+U4g9oT9hoz6TyxcYb6WtqTgSP2tm3BeDOnNiaWctw=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Y8uIOsvjzvGdysVIxHgoZY8WSqBlgd7Ug5oGoEdouyeegqJp5Y/uHYC+nVhBs2IV5 V4azNNlOtLf6AlS/SyqVaSVmENRCiNmxuTMNdnF5oGYwNx0tSr9mGAas1dTmn1g7a2 6DX9hJn5zSxWOgPUkjCSGUFm7cBq0Hv87Q4jfnxhPvnv23zD8fdo1RKOro5yURIdUn pAxDUuWtPwxazrksTc4xApsfCibJKvnxWZqGe/hJEGKJA7l9y/H31AxaPG5RCiizy7 MvDFrLa9HBGIRh/O54u+92MB+ZZKjYIzFkoutUdGDulvDm28ei6YO+oxXCjUusl4Qv 2lkyFZWRtKtJg== Date: Tue, 6 Dec 2022 12:02:35 +0200 From: Leon Romanovsky To: Yuan Can Cc: jesse.brandeburg@intel.com, anthony.l.nguyen@intel.com, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, jeffrey.t.kirsher@intel.com, alice.michael@intel.com, piotr.marczak@intel.com, intel-wired-lan@lists.osuosl.org, netdev@vger.kernel.org Subject: Re: [PATCH] intel/i40e: Fix potential memory leak in i40e_init_recovery_mode() Message-ID: References: <20221206092613.122952-1-yuancan@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20221206092613.122952-1-yuancan@huawei.com> Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org On Tue, Dec 06, 2022 at 09:26:13AM +0000, Yuan Can wrote: > If i40e_vsi_mem_alloc() failed in i40e_init_recovery_mode(), the pf will be > freed with the pf->vsi leaked. > Fix by free pf->vsi in the error handling path. > > Fixes: 4ff0ee1af016 ("i40e: Introduce recovery mode support") > Signed-off-by: Yuan Can > --- > drivers/net/ethernet/intel/i40e/i40e_main.c | 1 + > 1 file changed, 1 insertion(+) The patch title needs to be "[PATCH net]..." > > diff --git a/drivers/net/ethernet/intel/i40e/i40e_main.c b/drivers/net/ethernet/intel/i40e/i40e_main.c > index b5dcd15ced36..d23081c224d6 100644 > --- a/drivers/net/ethernet/intel/i40e/i40e_main.c > +++ b/drivers/net/ethernet/intel/i40e/i40e_main.c > @@ -15536,6 +15536,7 @@ static int i40e_init_recovery_mode(struct i40e_pf *pf, struct i40e_hw *hw) > pci_disable_pcie_error_reporting(pf->pdev); > pci_release_mem_regions(pf->pdev); > pci_disable_device(pf->pdev); > + kfree(pf->vsi); > kfree(pf); > > return err; The change is ok, but it is worth to cleanup error flow of i40e_probe and i40e_remove as they are not really in the same order. Thanks, Reviewed-by: Leon Romanovsky