Skip to contentSkip to conversation

ethdev: check if queues are allocated before getting info

PATCH In review Ferruh Yigit 2 participants 3 messages Oct 1, 2020 – Oct 5, 2020

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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")
---
 lib/librte_ethdev/rte_ethdev.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
lib/librte_ethdev/rte_ethdev.c +4 -2
index 0f56541fbc..9805184633 100644
@@ -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",
Signature · 1 line
2.26.2
Reviewed-by on v1 1/1
#1 lore raw
Quoted 5 lines · Ferruh Yigit

A crash is detected when '--txpkts=#' parameter provided to the testpmd, this is because queue information is requested before queues have been allocated.

Quoted 7 lines

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")
Quoted 31 lines
---
 lib/librte_ethdev/rte_ethdev.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
lib/librte_ethdev/rte_ethdev.c +4 -3
index 0f56541fbc..9805184633 100644
@@ -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",
--

2.26.2

author Applied
#2 lore raw
Quoted 10 lines · Ajit Khaparde
Quoted 9 lines · Ferruh Yigit

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.

Quoted 6 lines
Quoted 3 lines
Fixes ba2fb4f022fc ("ethdev: check if queue setup when getting queue info")

Applied to dpdk-next-net/main, thanks.