From 32b12e75679230b1104b9e6547a1ff3c4a360e05 Mon Sep 17 00:00:00 2001 From: Raslsn Darawsheh Date: Mon, 26 Oct 2015 09:07:57 +0200 Subject: [PATCH] bonding: fix freeing with no queue 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 Signed-off-by: Yaacov Hazan Acked-by: Declan Doherty --- 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 500a1eefe9..bbff664bd6 100644 --- a/drivers/net/bonding/rte_eth_bond_pmd.c +++ b/drivers/net/bonding/rte_eth_bond_pmd.c @@ -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 -- 2.20.1