From patchwork Thu Sep 16 14:04:00 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qiming Chen X-Patchwork-Id: 99033 X-Patchwork-Delegate: qi.z.zhang@intel.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 4CEA3A0C45; Thu, 16 Sep 2021 16:04:53 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id D6F58410FC; Thu, 16 Sep 2021 16:04:52 +0200 (CEST) Received: from mail-m974.mail.163.com (mail-m974.mail.163.com [123.126.97.4]) by mails.dpdk.org (Postfix) with ESMTP id DF39A410FA; Thu, 16 Sep 2021 16:04:49 +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=FElgW YagTGCCpBDgg9h2KFp2cFWNmb/rOnbQrZ/ZQsk=; b=gckilKZmJo/j6tZNZITFU 7+iNPVX502K5h3zG9/H03gA5PnyoAgB5zUD5OvThFbQXfdgTZ5kV/nRtKIkbXNxF a9Jejnlwckh/p+fYYN9/p7Swhpvylio7eObidUwthRBQ14Nz64xdVXhtXIRrBeu7 w9MknwTtb4OPTqX/MXN7Pw= Received: from localhost.localdomain (unknown [124.160.213.250]) by smtp4 (Coremail) with SMTP id HNxpCgB3_gf7TkNhkisFDA--.8209S2; Thu, 16 Sep 2021 22:04:45 +0800 (CST) From: Qiming Chen To: dev@dpdk.org Cc: beilei.xing@intel.com, jingjing.wu@intel.com, Qiming Chen , stable@dpdk.org Date: Thu, 16 Sep 2021 22:04:00 +0800 Message-Id: <20210916140400.1982-1-chenqiming_huawei@163.com> X-Mailer: git-send-email 2.30.1.windows.1 In-Reply-To: <20210910083138.12867-1-chenqiming_huawei@163.com> References: <20210910083138.12867-1-chenqiming_huawei@163.com> MIME-Version: 1.0 X-CM-TRANSID: HNxpCgB3_gf7TkNhkisFDA--.8209S2 X-Coremail-Antispam: 1Uf129KBjvJXoW7ZrWfXFW7WFWUXw15Ww48JFb_yoW8WFy8pr Z3G347Ary8tanrW34xKr4ruwn3G3yfKry2gFZ7Zas5u34F9ry8WrWUJFW0vF1kKF1kKa1a yF1UZFsxGFnxZ37anT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07UMlk3UUUUU= X-Originating-IP: [124.160.213.250] X-CM-SenderInfo: xfkh01xlpl0w5bkxt4lhl6il2tof0z/1tbiQBYQoFSIkFq+GAAAsW Subject: [dpdk-dev] [PATCH v2] net/iavf: fix mbuf 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" In the iavf_dev_rx_queue_start function, if the iavf_switch_queue or iavf_switch_queue_lv function fails, the previously applied mbuf is not released, resulting in leakage. The patch fixes the problem. Fixes: 9cf9c02bf6ee ("net/iavf: add enable/disable queues for large VF") Cc: stable@dpdk.org Signed-off-by: Qiming Chen Acked-by: Qi Zhang --- v2: Solve the potential mbuf leak of the alloc_rxq_mbufs function itself. --- drivers/net/iavf/iavf_rxtx.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/drivers/net/iavf/iavf_rxtx.c b/drivers/net/iavf/iavf_rxtx.c index e33fe4576b..7ec4f241e2 100644 --- a/drivers/net/iavf/iavf_rxtx.c +++ b/drivers/net/iavf/iavf_rxtx.c @@ -274,11 +274,15 @@ alloc_rxq_mbufs(struct iavf_rx_queue *rxq) volatile union iavf_rx_desc *rxd; struct rte_mbuf *mbuf = NULL; uint64_t dma_addr; - uint16_t i; + uint16_t i, j; for (i = 0; i < rxq->nb_rx_desc; i++) { mbuf = rte_mbuf_raw_alloc(rxq->mp); if (unlikely(!mbuf)) { + for (j = 0; j < i; j++) { + rte_pktmbuf_free_seg(rxq->sw_ring[j]); + rxq->sw_ring[j] = NULL; + } PMD_DRV_LOG(ERR, "Failed to allocate mbuf for RX"); return -ENOMEM; } @@ -848,12 +852,14 @@ iavf_dev_rx_queue_start(struct rte_eth_dev *dev, uint16_t rx_queue_id) else err = iavf_switch_queue_lv(adapter, rx_queue_id, true, true); - if (err) + if (err) { + release_rxq_mbufs(rxq); PMD_DRV_LOG(ERR, "Failed to switch RX queue %u on", rx_queue_id); - else + } else { dev->data->rx_queue_state[rx_queue_id] = RTE_ETH_QUEUE_STATE_STARTED; + } return err; }