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 0D39BA034F; Fri, 10 Sep 2021 09:49:30 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 9719F40041; Fri, 10 Sep 2021 09:49:30 +0200 (CEST) Received: from mail-m975.mail.163.com (mail-m975.mail.163.com [123.126.97.5]) by mails.dpdk.org (Postfix) with ESMTP id 9DAA44003E; Fri, 10 Sep 2021 09:49:28 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:Subject:Date:Message-Id:MIME-Version; bh=pSFZ4 dK+B6IQ94Om/a5wH7ZzMg8vReGGsTs73bakWLQ=; b=iRvAij1u0FeNo2kNI0/Ij yF4LKJgvThfcrkIuEaznmLFnc7NO0+aA4SWKDi8fjWEWKFK6c3amPBXDyjq/coVr WbHRnGS7cQ5UbRGLVY7fSgnquWF9UorNYzXhb1LYsg2qZpWXajEgIspz3qy7YJfS vKGgqjP2f8Zza/ra5ez02s= Received: from localhost.localdomain (unknown [124.160.213.250]) by smtp5 (Coremail) with SMTP id HdxpCgA3L9gDDjthuM9sAA--.773S2; Fri, 10 Sep 2021 15:49:26 +0800 (CST) From: Qiming Chen To: dev@dpdk.org Cc: beilei.xing@intel.com, jingjing.wu@intel.com, Qiming Chen , stable@dpdk.org Date: Fri, 10 Sep 2021 15:48:35 +0800 Message-Id: <20210910074835.12176-1-chenqiming_huawei@163.com> X-Mailer: git-send-email 2.30.1.windows.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID: HdxpCgA3L9gDDjthuM9sAA--.773S2 X-Coremail-Antispam: 1Uf129KBjvJXoW7Zw4ftF4UGFWkAFyxtr4fZrb_yoW8tF1kpa y3Wa4rtFy8JFsrG3yfJFWrA3W3C3yfJw17CFZxCasxC3yrAr93Xry0ya4qyFnYqrZ7CF4a qFsYk3Zrurs0kFDanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07jx5rcUUUUU= X-Originating-IP: [124.160.213.250] X-CM-SenderInfo: xfkh01xlpl0w5bkxt4lhl6il2tof0z/1tbiDgcKoFXl1RZqzwAAs1 Subject: [dpdk-dev] [PATCH] net/iavf: fix vf probe resource leak 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 Sender: "dev" During the port probe process, there are two abnormal branches that did not release the previously requested memory, resulting in leakage. The patch adds an iavf_uninit_vf function, which corresponds to the iavf_init_vf function. Fixes: ff2d0c345c3b ("net/iavf: support generic flow API") Cc: stable@dpdk.org Signed-off-by: Qiming Chen --- drivers/net/iavf/iavf_ethdev.c | 38 ++++++++++++++++++++++++++++++++-- 1 file changed, 36 insertions(+), 2 deletions(-) diff --git a/drivers/net/iavf/iavf_ethdev.c b/drivers/net/iavf/iavf_ethdev.c index 280d53a651..6ed2dbbcbe 100644 --- a/drivers/net/iavf/iavf_ethdev.c +++ b/drivers/net/iavf/iavf_ethdev.c @@ -2195,6 +2195,30 @@ iavf_init_vf(struct rte_eth_dev *dev) return -1; } +static void +iavf_uninit_vf(struct rte_eth_dev *dev) +{ + struct iavf_hw *hw = IAVF_DEV_PRIVATE_TO_HW(dev->data->dev_private); + struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(dev->data->dev_private); + + iavf_shutdown_adminq(hw); + + rte_free(vf->vf_res); + vf->vsi_res = NULL; + vf->vf_res = NULL; + + rte_free(vf->aq_resp); + vf->aq_resp = NULL; + + rte_free(vf->qos_cap); + vf->qos_cap = NULL; + + rte_free(vf->rss_lut); + vf->rss_lut = NULL; + rte_free(vf->rss_key); + vf->rss_key = NULL; +} + /* Enable default admin queue interrupt setting */ static inline void iavf_enable_irq0(struct iavf_hw *hw) @@ -2323,7 +2347,8 @@ iavf_dev_init(struct rte_eth_dev *eth_dev) PMD_INIT_LOG(ERR, "Failed to allocate %d bytes needed to" " store MAC addresses", RTE_ETHER_ADDR_LEN * IAVF_NUM_MACADDR_MAX); - return -ENOMEM; + ret = -ENOMEM; + goto init_vf_err; } /* If the MAC address is not configured by host, * generate a random one. @@ -2348,12 +2373,21 @@ iavf_dev_init(struct rte_eth_dev *eth_dev) ret = iavf_flow_init(adapter); if (ret) { PMD_INIT_LOG(ERR, "Failed to initialize flow"); - return ret; + goto flow_init_err; } iavf_default_rss_disable(adapter); return 0; + +flow_init_err: + rte_free(eth_dev->data->mac_addrs); + eth_dev->data->mac_addrs = NULL; + +init_vf_err: + iavf_uninit_vf(eth_dev); + + return ret; } static int -- 2.30.1.windows.1