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 8F2EFA034E; Tue, 22 Feb 2022 19:20:14 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 0C5944115D; Tue, 22 Feb 2022 19:19:33 +0100 (CET) Received: from out203-205-251-82.mail.qq.com (out203-205-251-82.mail.qq.com [203.205.251.82]) by mails.dpdk.org (Postfix) with ESMTP id 9ED2440DF6 for ; Tue, 22 Feb 2022 19:19:30 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foxmail.com; s=s201512; t=1645553969; bh=0qtYDZdlDpQ65AzxXs+i5eMnOuK10KPt+MmkVZWNsaA=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=jWAZsYjz+enPdrkPluYZwiVEgakDLE0DoUHNms+ieavX3nM64DQIVjgyiudRX1G/Z UIR5z9RqDaUCeMoHwdY2inLodFuTBaLdzZUYcedQI5QzTQvMBcxgV5SCkmZAoFRx3+ qRC3ZTSko8dGsEDxHMyw8HlVJKldsPhnQ4W7hkXM= 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: xmsmtpt1645553964t1ce6m321 Message-ID: X-QQ-XMAILINFO: N6qfSVgljG6X2orpMhL4RfcnoBdDN6O43Ci1k5Om3itXxrlZLaCew56rCm6F0n 42rn2+Tw0aV8jFcy5eJwzb6Bb4T+WccIcxiCbj6zIOSnUN/nYAZbFZTlEp7C9CUHUCfK+OANKwFD IUfdo3ywnqIZW6GMNDUhmLXly1aaaGOOp1Vawkks0edSEUZfaFoDaC3MyKkdDmoTIlScF2FvNDQx 8Q2pjERrzwtNGFA8uUAMMgXtB1U3KD6XVfaTfjkR8fNartIxr2BmQrXIi9sJLISVuHVJTibIwjdO iWe8NRAcLA38VdKuQvG/ORmy+2cyiNHoTpcund8CvhtIibf/jC00N62ikAPBm4uc7GZmzF+snd9i KeSpkdk+xX9IR/B+OTOp2/rv+pdSG6hY4fyAiqiOP8bVfWBKuWdW8OOkg/3M0bLidZxjyzuDMSLu boT9ak3tZ/O9MmazDRWZuL+v4IUvzfByWp6eNwbxET0nfBvoeos0OLdz29vp1T/6tNVH2s/Pzppv l/Hu1PEFnQMXZmdWtPmaoOX7Y4ezX/ywKmtKuy6qw7E0YilvK5dRr9F4T1ECSkq+7ci1IHW0JwkB vXBZ4FTBglOPZN0USvAtVPmkwbaVpJrz0FHjtmhQmPtG6l3pYH2oqD3HXjJR1MOtugY4cEGRjUHM A9YQIaR+ZSlE6HsN0A/sAQs7+E4Bhd+epYtB06gknxq1qlnHCSaGQCnOUKLsmE9ZS6bcTlGOKv08 qJbWS2mE9PbOyAL/BVp1t+/oZAn1YaOwc0zXLrdTIphuMsU81Ci4RouvAenNlC4Y5osMeoqVoGGf YYP2t6AQ6pbho5PMWYmptM0B0mbrr7h0H5rIYBGcUYjdTFFX8OYfLmFiaFhgjh5+a3RnGv+yIt++ K9LHQYW8G0OSk8YiVoIQ2fzWjoLrMwlQ== 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 17/20] net/vmxnet3: fix memory leaks in error handlings Date: Wed, 23 Feb 2022 02:18:15 +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 1) in function vmxnet3_dev_tx_queue_setup(): The momory of 'txq' is stored to 'dev->data->tx_queues[queue_idx]' at the end of the function. When function returned early in the error handling, 'txq' is not released which leads to a memory leak. 2) in function vmxnet3_dev_rx_queue_setup(): Same reason to case 1) with memory 'rxq'. Fixes: dfaff37fc46d ("vmxnet3: import new vmxnet3 poll mode driver implementation") Signed-off-by: Weiguo Li --- drivers/net/vmxnet3/vmxnet3_rxtx.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/net/vmxnet3/vmxnet3_rxtx.c b/drivers/net/vmxnet3/vmxnet3_rxtx.c index d745064bc4..3d1c6080e8 100644 --- a/drivers/net/vmxnet3/vmxnet3_rxtx.c +++ b/drivers/net/vmxnet3/vmxnet3_rxtx.c @@ -1057,10 +1057,12 @@ vmxnet3_dev_tx_queue_setup(struct rte_eth_dev *dev, /* Tx vmxnet ring length should be between 512-4096 */ if (nb_desc < VMXNET3_DEF_TX_RING_SIZE) { + rte_free(txq); PMD_INIT_LOG(ERR, "VMXNET3 Tx Ring Size Min: %u", VMXNET3_DEF_TX_RING_SIZE); return -EINVAL; } else if (nb_desc > VMXNET3_TX_RING_MAX_SIZE) { + rte_free(txq); PMD_INIT_LOG(ERR, "VMXNET3 Tx Ring Size Max: %u", VMXNET3_TX_RING_MAX_SIZE); return -EINVAL; @@ -1084,6 +1086,7 @@ vmxnet3_dev_tx_queue_setup(struct rte_eth_dev *dev, mz = rte_eth_dma_zone_reserve(dev, "txdesc", queue_idx, size, VMXNET3_RING_BA_ALIGN, socket_id); if (mz == NULL) { + rte_free(txq); PMD_INIT_LOG(ERR, "ERROR: Creating queue descriptors zone"); return -ENOMEM; } @@ -1108,6 +1111,7 @@ vmxnet3_dev_tx_queue_setup(struct rte_eth_dev *dev, ring->buf_info = rte_zmalloc("tx_ring_buf_info", ring->size * sizeof(vmxnet3_buf_info_t), RTE_CACHE_LINE_SIZE); if (ring->buf_info == NULL) { + rte_free(txq); PMD_INIT_LOG(ERR, "ERROR: Creating tx_buf_info structure"); return -ENOMEM; } @@ -1163,9 +1167,11 @@ vmxnet3_dev_rx_queue_setup(struct rte_eth_dev *dev, /* Rx vmxnet rings length should be between 256-4096 */ if (nb_desc < VMXNET3_DEF_RX_RING_SIZE) { + rte_free(rxq); PMD_INIT_LOG(ERR, "VMXNET3 Rx Ring Size Min: 256"); return -EINVAL; } else if (nb_desc > VMXNET3_RX_RING_MAX_SIZE) { + rte_free(rxq); PMD_INIT_LOG(ERR, "VMXNET3 Rx Ring Size Max: 4096"); return -EINVAL; } else { @@ -1195,6 +1201,7 @@ vmxnet3_dev_rx_queue_setup(struct rte_eth_dev *dev, mz = rte_eth_dma_zone_reserve(dev, "rxdesc", queue_idx, size, VMXNET3_RING_BA_ALIGN, socket_id); if (mz == NULL) { + rte_free(rxq); PMD_INIT_LOG(ERR, "ERROR: Creating queue descriptors zone"); return -ENOMEM; } @@ -1233,6 +1240,7 @@ vmxnet3_dev_rx_queue_setup(struct rte_eth_dev *dev, ring->size * sizeof(vmxnet3_buf_info_t), RTE_CACHE_LINE_SIZE); if (ring->buf_info == NULL) { + rte_free(rxq); PMD_INIT_LOG(ERR, "ERROR: Creating rx_buf_info structure"); return -ENOMEM; } -- 2.25.1