net/mlx5: fix segfault on interrupt disable
authorShahaf Shuler <shahafs@mellanox.com>
Tue, 17 Oct 2017 12:04:56 +0000 (15:04 +0300)
committerFerruh Yigit <ferruh.yigit@intel.com>
Thu, 26 Oct 2017 00:33:00 +0000 (02:33 +0200)
Interrupt disable can be called when the interrupt vector is not yet
allocated. Such case ends up with segmentation fault.

Fixing it by adding verification for interrupt vector validity.

Fixes: 09cb5b581762 ("net/mlx5: separate DPDK from verbs Rx queue objects")

Signed-off-by: Shahaf Shuler <shahafs@mellanox.com>
Acked-by: Nelio Laranjeiro <nelio.laranjeiro@6wind.com>
drivers/net/mlx5/mlx5_rxq.c

index ad741ef..2beebfd 100644 (file)
@@ -396,6 +396,8 @@ priv_rx_intr_vec_disable(struct priv *priv)
 
        if (!priv->dev->data->dev_conf.intr_conf.rxq)
                return;
+       if (!intr_handle->intr_vec)
+               goto free;
        for (i = 0; i != n; ++i) {
                struct mlx5_rxq_ctrl *rxq_ctrl;
                struct mlx5_rxq_data *rxq_data;
@@ -411,8 +413,10 @@ priv_rx_intr_vec_disable(struct priv *priv)
                rxq_ctrl = container_of(rxq_data, struct mlx5_rxq_ctrl, rxq);
                mlx5_priv_rxq_ibv_release(priv, rxq_ctrl->ibv);
        }
+free:
        rte_intr_free_epoll_fd(intr_handle);
-       free(intr_handle->intr_vec);
+       if (intr_handle->intr_vec)
+               free(intr_handle->intr_vec);
        intr_handle->nb_efd = 0;
        intr_handle->intr_vec = NULL;
 }