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 485F743DE7; Wed, 3 Apr 2024 12:21:56 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 3CFDE402EC; Wed, 3 Apr 2024 12:21:48 +0200 (CEST) Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by mails.dpdk.org (Postfix) with ESMTP id 28CA2402D1 for ; Wed, 3 Apr 2024 12:21:45 +0200 (CEST) Received: from mail.maildlp.com (unknown [172.19.163.174]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4V8ghY5TT6ztRcD; Wed, 3 Apr 2024 18:19:09 +0800 (CST) Received: from kwepemd100004.china.huawei.com (unknown [7.221.188.31]) by mail.maildlp.com (Postfix) with ESMTPS id 1892B140FB0; Wed, 3 Apr 2024 18:21:44 +0800 (CST) Received: from localhost.localdomain (10.67.165.2) by kwepemd100004.china.huawei.com (7.221.188.31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1258.28; Wed, 3 Apr 2024 18:21:43 +0800 From: Jie Hai To: , Yisen Zhuang , Hao Chen , "Wei Hu (Xavier)" , "Min Wang (Jushui)" , "Min Hu (Connor)" , Huisong Li CC: , , , Subject: [PATCH 3/5] net/hns3: fix double free for Rx/Tx queue Date: Wed, 3 Apr 2024 18:16:21 +0800 Message-ID: <20240403101624.2771140-4-haijie1@huawei.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20240403101624.2771140-1-haijie1@huawei.com> References: <20240403101624.2771140-1-haijie1@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.67.165.2] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To kwepemd100004.china.huawei.com (7.221.188.31) 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 From: Dengdui Huang The Pointers to some resources on the Rx/Tx queue need to be set to NULL after free inside the hns3_rx/tx_queue_release(), as this function is called from multiple threads (reset thread, device config thread, etc), leading to double memory free error. Fixes: bba636698316 ("net/hns3: support Rx/Tx and related operations") Cc: stable@dpdk.org Signed-off-by: Dengdui Huang Signed-off-by: Jie Hai --- drivers/net/hns3/hns3_rxtx.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/drivers/net/hns3/hns3_rxtx.c b/drivers/net/hns3/hns3_rxtx.c index 54bf724a0e6c..fbc5ef3225c5 100644 --- a/drivers/net/hns3/hns3_rxtx.c +++ b/drivers/net/hns3/hns3_rxtx.c @@ -86,9 +86,14 @@ hns3_rx_queue_release(void *queue) struct hns3_rx_queue *rxq = queue; if (rxq) { hns3_rx_queue_release_mbufs(rxq); - if (rxq->mz) + if (rxq->mz) { rte_memzone_free(rxq->mz); - rte_free(rxq->sw_ring); + rxq->mz = NULL; + } + if (rxq->sw_ring) { + rte_free(rxq->sw_ring); + rxq->sw_ring = NULL; + } rte_free(rxq); } } @@ -99,10 +104,18 @@ hns3_tx_queue_release(void *queue) struct hns3_tx_queue *txq = queue; if (txq) { hns3_tx_queue_release_mbufs(txq); - if (txq->mz) + if (txq->mz) { rte_memzone_free(txq->mz); - rte_free(txq->sw_ring); - rte_free(txq->free); + txq->mz = NULL; + } + if (txq->sw_ring) { + rte_free(txq->sw_ring); + txq->sw_ring = NULL; + } + if (txq->free) { + rte_free(txq->free); + txq->free = NULL; + } rte_free(txq); } } -- 2.30.0