From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id CCAE8A034E; Tue, 22 Feb 2022 19:20:22 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 2929941C27; Tue, 22 Feb 2022 19:19:35 +0100 (CET) Received: from out203-205-221-233.mail.qq.com (out203-205-221-233.mail.qq.com [203.205.221.233]) by mails.dpdk.org (Postfix) with ESMTP id E57BF40DF6 for ; Tue, 22 Feb 2022 19:19:31 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foxmail.com; s=s201512; t=1645553965; bh=Fct4t/z/07DfWsYeJvTHuJ9oWM8lG9O3VECwOFSzB5o=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=W/Ayvq7J3Su76vAOAbvHFkBSX2HKDLhVsPZQt8FBCOBb4mfKizdkmuqjgWCL2aJNP 7wqhUQ+UvfWTKfDAaWQZLTcEEa8uC1mXeu5CuQv8Nhutyiix9hbb2ZfQuOuQlEijc2 c/drbV9BaFyBQ+oPcPOdOL/P1X/ob09mXKj1422Y= Received: from localhost.localdomain ([111.193.130.237]) by newxmesmtplogicsvrszc6.qq.com (NewEsmtp) with SMTP id 49223207; Wed, 23 Feb 2022 02:18:18 +0800 X-QQ-mid: xmsmtpt1645553961t7df7kpia Message-ID: X-QQ-XMAILINFO: M1xqn9pGP6LNPjui4LppxAp/CE39U3eilBtkieK4+w4YlAwrUTEEhuTy8dJ/zG D+UbSD9othT0r+SafeUGmipvCi5KX9uh2hZW8rda57V8G+j6+7wsUq6H0M8Twq/dC9LLYi3H41Sb 8URGJyvqekj14tCZZtsoImsZ/77lj2X9LSNxwjDtOqlfFPBDZW46kjS5R6PUFXmtXrJaSFsmvJXx QYp4zKV8SmFcN0WvpQ8ovdWdpX6y+09Y9im1QT2KB8Qk4x+fqFrPGTqNZPUYfh/blXQ7ue2JhwyM MjG41++pNn+5hWN5ICvtupSqvuUstxCRj/7cWBMg2SaNJy+LJjqf8NmZ8Tp55gk4AEQQfcOw388Q U8M8DsdVid9UtfaITPBUUG/VwiH8LOwH82F7nsfU6Gw0H5yRPfbzOdtXBFpjWy2vAV3ii42QA7Xr mxoRMNS6kVrPQOrwfWdUnBXyyxwYsbsKPEE6qAN8oIycqXIATf2VIQXqvykDtVZMOA9smw46j9tO vIexFgvq8Ca3o9bDgI6OKjTFso+yn1JRyWHjttOx8sv3cVbIKWGILSWU+9p+eHx3bzJVo7geo0vX TCAqnKY5s1AmZFATRlOcZk2qHkRnyVAvTQQ9N/EZT7iEsdr9cf0n9fnEqRRmcYCUZmNHixqKGwLf BSFouny2pxAEJ/3gtoqS0OYb9beWgiDJgJJXlfXoGGhZmmvbPRdxkRKi2xonLPHw5ppGiy+no0Rk 8ljA02QKbZ/247u0aOggn+xlHY4eudwpwLVS9ae2HU2KdOvfxU36+eUXvEvRahtBLuf2yYJtSEY4 auMNAHjbeJhl/ZJyO4hXfJSA4nWZ7nHLwSyopyQRewMKlDKJ0a+m9dmITDLyWZhBxoDQXNLoY+PE y6UXKyk6R9nmyJCn3D8qo= From: Weiguo Li To: dev@dpdk.org Cc: adypodoman@gmail.com, xiaoyun.li@intel.com, tianfei.zhang@intel.com, bruce.richardson@intel.com, ivan.malov@oktetlabs.ru, jgrajcia@cisco.com, hkalra@marvell.com, ying.a.wang@intel.com, ting.xu@intel.com, simei.su@intel.com, qiming.yang@intel.com, motih@mellanox.com, shreyansh.jain@nxp.com, skoteshwar@marvell.com, stephen@networkplumber.org, kalesh-anakkur.purayil@broadcom.com, somnath.kotur@broadcom.com, declan.doherty@intel.com, gakhil@marvell.com, nicolas.chautru@intel.com Subject: [PATCH 16/20] net/sfc: fix a memory leak in error handling Date: Wed, 23 Feb 2022 02:18:14 +0800 X-OQ-MSGID: X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org When efx_nic_get_board_info() failed then function return, the memory in 'id' is not released, this leads to a memory leak. Fixes: e86b48aa46d4 ("net/sfc: add HW switch ID helpers") Signed-off-by: Weiguo Li --- drivers/net/sfc/sfc.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/net/sfc/sfc.c b/drivers/net/sfc/sfc.c index 51726d229b..ad1683a512 100644 --- a/drivers/net/sfc/sfc.c +++ b/drivers/net/sfc/sfc.c @@ -1423,8 +1423,10 @@ sfc_hw_switch_id_init(struct sfc_adapter *sa, return ENOMEM; rc = efx_nic_get_board_info(sa->nic, &board_info); - if (rc != 0) + if (rc != 0) { + rte_free(id); return rc; + } memcpy(id->board_sn, board_info.enbi_serial, sizeof(id->board_sn)); -- 2.25.1