From: Ferruh Yigit Date: Thu, 1 Oct 2020 18:14:02 +0000 (+0100) Subject: ethdev: check if queues are allocated before getting info X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=7ae5c75f374c058bd0d74f5f7f50591286bfd925;p=dpdk.git ethdev: check if queues are allocated before getting info A crash is detected when '--txpkts=#' parameter provided to the testpmd, this is because queue information is requested before queues have been allocated. Adding check to queue info APIs ('rte_eth_rx_queue_info_get()' & 'rte_eth_tx_queue_info_get') to protect against similar cases. Fixes: ba2fb4f022fc ("ethdev: check if queue setup when getting queue info") Signed-off-by: Ferruh Yigit Reviewed-by: Ajit Khaparde --- diff --git a/lib/librte_ethdev/rte_ethdev.c b/lib/librte_ethdev/rte_ethdev.c index b51ab9b5bf..89858ab42e 100644 --- a/lib/librte_ethdev/rte_ethdev.c +++ b/lib/librte_ethdev/rte_ethdev.c @@ -4688,7 +4688,8 @@ rte_eth_rx_queue_info_get(uint16_t port_id, uint16_t queue_id, return -EINVAL; } - if (dev->data->rx_queues[queue_id] == NULL) { + if (dev->data->rx_queues == NULL || + dev->data->rx_queues[queue_id] == NULL) { RTE_ETHDEV_LOG(ERR, "Rx queue %"PRIu16" of device with port_id=%" PRIu16" has not been setup\n", @@ -4727,7 +4728,8 @@ rte_eth_tx_queue_info_get(uint16_t port_id, uint16_t queue_id, return -EINVAL; } - if (dev->data->tx_queues[queue_id] == NULL) { + if (dev->data->tx_queues == NULL || + dev->data->tx_queues[queue_id] == NULL) { RTE_ETHDEV_LOG(ERR, "Tx queue %"PRIu16" of device with port_id=%" PRIu16" has not been setup\n",