[dpdk-dev] [PATCH v2] net:bonding: fix free_queues function when no queues exist

Yaacov Hazan yaacovh at mellanox.com
Mon Oct 26 08:07:57 CET 2015


From: Raslsn Darawsheh <rdarawsheh at asaltech.com>

In case of creating bond device without add any slaves and
quit from testpmd, application crashed since rx/tx queues
are NULL.

add checking of this paramters before trying to free.

Signed-off-by: Raslsn Darawsheh <rdarawsheh at asaltech.com>
Signed-off-by: Yaacov Hazan <yaacovh at mellanox.com>
---
in previous patch there was mismatch in the solution.
this patch is the correct fix for the described bug

 drivers/net/bonding/rte_eth_bond_pmd.c | 20 ++++++++++++--------
 1 file changed, 12 insertions(+), 8 deletions(-)

diff --git a/drivers/net/bonding/rte_eth_bond_pmd.c b/drivers/net/bonding/rte_eth_bond_pmd.c
index 5cc6372..383fdcf 100644
--- a/drivers/net/bonding/rte_eth_bond_pmd.c
+++ b/drivers/net/bonding/rte_eth_bond_pmd.c
@@ -1517,17 +1517,21 @@ bond_ethdev_free_queues(struct rte_eth_dev *dev)
 {
 	uint8_t i;
 
-	for (i = 0; i < dev->data->nb_rx_queues; i++) {
-		rte_free(dev->data->rx_queues[i]);
-		dev->data->rx_queues[i] = NULL;
+	if (dev->data->rx_queues != NULL) {
+		for (i = 0; i < dev->data->nb_rx_queues; i++) {
+			rte_free(dev->data->rx_queues[i]);
+			dev->data->rx_queues[i] = NULL;
+		}
+		dev->data->nb_rx_queues = 0;
 	}
-	dev->data->nb_rx_queues = 0;
 
-	for (i = 0; i < dev->data->nb_tx_queues; i++) {
-		rte_free(dev->data->tx_queues[i]);
-		dev->data->tx_queues[i] = NULL;
+	if (dev->data->tx_queues != NULL) {
+		for (i = 0; i < dev->data->nb_tx_queues; i++) {
+			rte_free(dev->data->tx_queues[i]);
+			dev->data->tx_queues[i] = NULL;
+		}
+		dev->data->nb_tx_queues = 0;
 	}
-	dev->data->nb_tx_queues = 0;
 }
 
 void
-- 
1.9.1



More information about the dev mailing list