net/mlx5: fix crash when setting hairpin queues
authorTonghao Zhang <xiangxia.m.yue@gmail.com>
Wed, 27 Nov 2019 14:18:41 +0000 (22:18 +0800)
committerFerruh Yigit <ferruh.yigit@intel.com>
Fri, 17 Jan 2020 18:45:23 +0000 (19:45 +0100)
If configuring the number of tx/rx queue with rte_eth_dev_configure
to nr_queues + hairpin_nr_queues, and setting tx/rx queues to
nr_queues with rte_eth_tx/rx_queue_setup. But not configuring the
hairpin queues via rte_eth_tx/rx_hairpin_queue_setup.

When starting the netdev, there is a crash because of NULL accessing.

Fixes: cf5516696d77 ("ethdev: add hairpin queue")
Cc: stable@dpdk.org
Signed-off-by: Tonghao Zhang <xiangxia.m.yue@gmail.com>
Acked-by: Ori Kam <orika@mellanox.com>
drivers/net/mlx5/mlx5_ethdev.c
drivers/net/mlx5/mlx5_trigger.c

index d80ae45..3b4c5db 100644 (file)
@@ -476,7 +476,7 @@ mlx5_dev_configure_rss_reta(struct rte_eth_dev *dev)
 
                rxq_data = (*priv->rxqs)[i];
                rxq_ctrl = container_of(rxq_data, struct mlx5_rxq_ctrl, rxq);
-               if (rxq_ctrl->type == MLX5_RXQ_TYPE_STANDARD)
+               if (rxq_ctrl && rxq_ctrl->type == MLX5_RXQ_TYPE_STANDARD)
                        rss_queue_arr[j++] = i;
        }
        rss_queue_n = j;
index cafab25..ab6937a 100644 (file)
@@ -106,9 +106,12 @@ mlx5_rxq_start(struct rte_eth_dev *dev)
        unsigned int i;
        int ret = 0;
        enum mlx5_rxq_obj_type obj_type = MLX5_RXQ_OBJ_TYPE_IBV;
+       struct mlx5_rxq_data *rxq = NULL;
 
        for (i = 0; i < priv->rxqs_n; ++i) {
-               if ((*priv->rxqs)[i]->lro) {
+               rxq = (*priv->rxqs)[i];
+
+               if (rxq && rxq->lro) {
                        obj_type =  MLX5_RXQ_OBJ_TYPE_DEVX_RQ;
                        break;
                }