bonding: fix freeing with no queue
authorRaslsn Darawsheh <rdarawsheh@asaltech.com>
Mon, 26 Oct 2015 07:07:57 +0000 (09:07 +0200)
committerThomas Monjalon <thomas.monjalon@6wind.com>
Wed, 4 Nov 2015 22:44:58 +0000 (23:44 +0100)
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 parameters before trying to free.

Signed-off-by: Raslsn Darawsheh <rdarawsheh@asaltech.com>
Signed-off-by: Yaacov Hazan <yaacovh@mellanox.com>
Acked-by: Declan Doherty <declan.doherty@intel.com>
drivers/net/bonding/rte_eth_bond_pmd.c

index 500a1ee..bbff664 100644 (file)
@@ -1558,17 +1558,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