ethdev: check if queue setup when getting queue info
authorWei Hu (Xavier) <xavier.huwei@huawei.com>
Mon, 24 Aug 2020 11:01:30 +0000 (19:01 +0800)
committerFerruh Yigit <ferruh.yigit@intel.com>
Fri, 18 Sep 2020 16:55:06 +0000 (18:55 +0200)
This patch adds checking whether the related Tx or Rx queue has been
setup in the rte_eth_rx_queue_info_get and rte_eth_tx_queue_info_get
API function to avoid illegal address access.

Signed-off-by: Wei Hu (Xavier) <xavier.huwei@huawei.com>
Reviewed-by: Ferruh Yigit <ferruh.yigit@intel.com>
lib/librte_ethdev/rte_ethdev.c

index 7858ad5..f8d63c7 100644 (file)
@@ -4670,6 +4670,14 @@ rte_eth_rx_queue_info_get(uint16_t port_id, uint16_t queue_id,
                return -EINVAL;
        }
 
+       if (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",
+                              queue_id, port_id);
+               return -EINVAL;
+       }
+
        if (rte_eth_dev_is_rx_hairpin_queue(dev, queue_id)) {
                RTE_ETHDEV_LOG(INFO,
                        "Can't get hairpin Rx queue %"PRIu16" info of device with port_id=%"PRIu16"\n",
@@ -4701,6 +4709,14 @@ rte_eth_tx_queue_info_get(uint16_t port_id, uint16_t queue_id,
                return -EINVAL;
        }
 
+       if (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",
+                              queue_id, port_id);
+               return -EINVAL;
+       }
+
        if (rte_eth_dev_is_tx_hairpin_queue(dev, queue_id)) {
                RTE_ETHDEV_LOG(INFO,
                        "Can't get hairpin Tx queue %"PRIu16" info of device with port_id=%"PRIu16"\n",