This patch fixes segfault which was triggered when port, with indirect
actions created, was closed. Segfault was occurring only when
RTE_LIBRTE_MLX5_DEBUG was defined. It was caused by redundant decrement
of RX queues refcount:

- refcount was decremented when port was stopped and indirect actions
were detached from RX queues (port stop),
- refcount was decremented when indirect actions objects were destroyed
(port close or destroying of indirect action).

With this patch RX queues refcounts are decremented if and only if
indirect actions object is detached or indirect actions object is
destroyed.

Fixes: ec4e11d41d12 ("net/mlx5: preserve indirect actions on restart")
Cc: dkozl...@nvidia.com

Signed-off-by: Dariusz Sosnowski <dsosnow...@nvidia.com>
Acked-by: Dmitry Kozlyuk <dkozl...@nvidia.com>
---
 drivers/net/mlx5/mlx5_rxq.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/drivers/net/mlx5/mlx5_rxq.c b/drivers/net/mlx5/mlx5_rxq.c
index 52b95d7070..b7af60df38 100644
--- a/drivers/net/mlx5/mlx5_rxq.c
+++ b/drivers/net/mlx5/mlx5_rxq.c
@@ -2214,8 +2214,15 @@ mlx5_ind_table_obj_release(struct rte_eth_dev *dev,
        if (ret)
                return 1;
        priv->obj_ops.ind_table_destroy(ind_tbl);
-       for (i = 0; i != ind_tbl->queues_n; ++i)
-               claim_nonzero(mlx5_rxq_deref(dev, ind_tbl->queues[i]));
+       /*
+        * Refcounts on RX queues are decremented if and only if indirection
+        * table was attached to RX queues. It will not be the case after
+        * calling mlx5_dev_stop.
+        */
+       if (priv->dev_data->dev_started) {
+               for (i = 0; i != ind_tbl->queues_n; ++i)
+                       claim_nonzero(mlx5_rxq_deref(dev, ind_tbl->queues[i]));
+       }
        mlx5_free(ind_tbl);
        return 0;
 }
-- 
2.25.1

Reply via email to