diff mbox series

[v4,3/3] ethdev: check if queue setupped when getting queue info

Message ID 20200824110130.16647-4-huwei013@chinasoftinc.com (mailing list archive)
State Accepted, archived
Delegated to: Ferruh Yigit
Headers show
Series minor updates for getting queue info | expand

Checks

Context Check Description
ci/Intel-compilation success Compilation OK
ci/travis-robot success Travis build: passed
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-testing success Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/checkpatch success coding style OK

Commit Message

Wei Hu (Xavier) Aug. 24, 2020, 11:01 a.m. UTC
From: "Wei Hu (Xavier)" <xavier.huwei@huawei.com>

This patch adds checking whether the related Tx or Rx queue has been
setuped 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>
---
 lib/librte_ethdev/rte_ethdev.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

Comments

Ferruh Yigit Aug. 25, 2020, 8:43 a.m. UTC | #1
On 8/24/2020 12:01 PM, Wei Hu (Xavier) wrote:
> From: "Wei Hu (Xavier)" <xavier.huwei@huawei.com>
> 
> This patch adds checking whether the related Tx or Rx queue has been
> setuped 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>
diff mbox series

Patch

diff --git a/lib/librte_ethdev/rte_ethdev.c b/lib/librte_ethdev/rte_ethdev.c
index 7858ad5f1..0503c7929 100644
--- a/lib/librte_ethdev/rte_ethdev.c
+++ b/lib/librte_ethdev/rte_ethdev.c
@@ -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 setuped\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 setuped\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",