DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH v2 1/4] net/dpaa: add null point check and fix mem leak
@ 2017-12-20 10:23 Yong Wang
  2017-12-20 10:23 ` [dpdk-dev] [PATCH v2 2/4] net/i40e: " Yong Wang
                   ` (4 more replies)
  0 siblings, 5 replies; 10+ messages in thread
From: Yong Wang @ 2017-12-20 10:23 UTC (permalink / raw)
  To: hemant.agrawal, beilei.xing, wenzhuo.lu, john.griffin; +Cc: dev, Yong Wang

Signed-off-by: Yong Wang <wang.yong19@zte.com.cn>
---
 drivers/net/dpaa/dpaa_ethdev.c | 36 +++++++++++++++++++++++++-----------
 1 file changed, 25 insertions(+), 11 deletions(-)

diff --git a/drivers/net/dpaa/dpaa_ethdev.c b/drivers/net/dpaa/dpaa_ethdev.c
index cf5a2ec..06d680c 100644
--- a/drivers/net/dpaa/dpaa_ethdev.c
+++ b/drivers/net/dpaa/dpaa_ethdev.c
@@ -877,12 +877,17 @@ static int dpaa_debug_queue_init(struct qman_fq *fq, uint32_t fqid)
 
 	dpaa_intf->rx_queues = rte_zmalloc(NULL,
 		sizeof(struct qman_fq) * num_rx_fqs, MAX_CACHELINE);
+	if (!dpaa_intf->rx_queues) {
+		DPAA_PMD_ERR("Failed to alloc mem for RX queues\n");
+		return -ENOMEM;
+	}
+
 	for (loop = 0; loop < num_rx_fqs; loop++) {
 		fqid = DPAA_PCD_FQID_START + dpaa_intf->ifid *
 			DPAA_PCD_FQID_MULTIPLIER + loop;
 		ret = dpaa_rx_queue_init(&dpaa_intf->rx_queues[loop], fqid);
 		if (ret)
-			return ret;
+			goto free_rx;
 		dpaa_intf->rx_queues[loop].dpaa_intf = dpaa_intf;
 	}
 	dpaa_intf->nb_rx_queues = num_rx_fqs;
@@ -891,14 +896,17 @@ static int dpaa_debug_queue_init(struct qman_fq *fq, uint32_t fqid)
 	num_cores = rte_lcore_count();
 	dpaa_intf->tx_queues = rte_zmalloc(NULL, sizeof(struct qman_fq) *
 		num_cores, MAX_CACHELINE);
-	if (!dpaa_intf->tx_queues)
-		return -ENOMEM;
+	if (!dpaa_intf->tx_queues) {
+		DPAA_PMD_ERR("Failed to alloc mem for TX queues\n");
+		ret = -ENOMEM;
+		goto free_rx;
+	}
 
 	for (loop = 0; loop < num_cores; loop++) {
 		ret = dpaa_tx_queue_init(&dpaa_intf->tx_queues[loop],
 					 fman_intf);
 		if (ret)
-			return ret;
+			goto free_tx;
 		dpaa_intf->tx_queues[loop].dpaa_intf = dpaa_intf;
 	}
 	dpaa_intf->nb_tx_queues = num_cores;
@@ -935,13 +943,8 @@ static int dpaa_debug_queue_init(struct qman_fq *fq, uint32_t fqid)
 		DPAA_PMD_ERR("Failed to allocate %d bytes needed to "
 						"store MAC addresses",
 				ETHER_ADDR_LEN * DPAA_MAX_MAC_FILTER);
-		rte_free(dpaa_intf->rx_queues);
-		rte_free(dpaa_intf->tx_queues);
-		dpaa_intf->rx_queues = NULL;
-		dpaa_intf->tx_queues = NULL;
-		dpaa_intf->nb_rx_queues = 0;
-		dpaa_intf->nb_tx_queues = 0;
-		return -ENOMEM;
+		ret = -ENOMEM;
+		goto free_tx;
 	}
 
 	/* copy the primary mac address */
@@ -967,6 +970,17 @@ static int dpaa_debug_queue_init(struct qman_fq *fq, uint32_t fqid)
 	fman_if_stats_reset(fman_intf);
 
 	return 0;
+
+free_tx:
+	rte_free(dpaa_intf->tx_queues);
+	dpaa_intf->tx_queues = NULL;
+	dpaa_intf->nb_tx_queues = 0;
+
+free_rx:
+	rte_free(dpaa_intf->rx_queues);
+	dpaa_intf->rx_queues = NULL;
+	dpaa_intf->nb_rx_queues = 0;
+	return ret;
 }
 
 static int
-- 
1.8.3.1

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2018-01-22  7:51 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-12-20 10:23 [dpdk-dev] [PATCH v2 1/4] net/dpaa: add null point check and fix mem leak Yong Wang
2017-12-20 10:23 ` [dpdk-dev] [PATCH v2 2/4] net/i40e: " Yong Wang
2017-12-27  6:41   ` Xing, Beilei
2017-12-20 10:23 ` [dpdk-dev] [PATCH v2 3/4] net/e1000: add null point check for rte_zmalloc Yong Wang
2017-12-20 10:23 ` [dpdk-dev] [PATCH v2 4/4] crypto/qat: add null point check and fix mem leak Yong Wang
2017-12-20 12:22   ` Trahe, Fiona
2017-12-20 12:58 ` [dpdk-dev] [PATCH v2 1/4] net/dpaa: " Shreyansh Jain
2018-01-17 23:00 ` Thomas Monjalon
2018-01-22  2:53   ` [dpdk-dev] 答复: " wang.yong19
2018-01-22  7:51     ` Thomas Monjalon

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).