From: Parav Pandit <[email protected]>

In below code flow, for ingress acl table root ns memory leads
to double free.

mlx5_init_fs
  init_ingress_acls_root_ns()
    init_ingress_acl_root_ns
       kfree(steering->esw_ingress_root_ns);
       /* steering->esw_ingress_root_ns is not marked NULL */
  mlx5_cleanup_fs
    cleanup_ingress_acls_root_ns
       steering->esw_ingress_root_ns non NULL check passes.
       kfree(steering->esw_ingress_root_ns);
       /* double free */

Similar issue exist for other tables.

Hence zero out the pointers to not process the table again.

Fixes: 9b93ab981e3bf ("net/mlx5: Separate ingress/egress namespaces for each 
vport")
Fixes: 40c3eebb49e51 ("net/mlx5: Add support in RDMA RX steering")
Signed-off-by: Parav Pandit <[email protected]>
Reviewed-by: Mark Bloch <[email protected]>
Signed-off-by: Saeed Mahameed <[email protected]>
---
 drivers/net/ethernet/mellanox/mlx5/core/fs_core.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/fs_core.c 
b/drivers/net/ethernet/mellanox/mlx5/core/fs_core.c
index 4fa87ca63bca..34276a2b6da2 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/fs_core.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/fs_core.c
@@ -2427,6 +2427,7 @@ static void cleanup_egress_acls_root_ns(struct 
mlx5_core_dev *dev)
                cleanup_root_ns(steering->esw_egress_root_ns[i]);
 
        kfree(steering->esw_egress_root_ns);
+       steering->esw_egress_root_ns = NULL;
 }
 
 static void cleanup_ingress_acls_root_ns(struct mlx5_core_dev *dev)
@@ -2441,6 +2442,7 @@ static void cleanup_ingress_acls_root_ns(struct 
mlx5_core_dev *dev)
                cleanup_root_ns(steering->esw_ingress_root_ns[i]);
 
        kfree(steering->esw_ingress_root_ns);
+       steering->esw_ingress_root_ns = NULL;
 }
 
 void mlx5_cleanup_fs(struct mlx5_core_dev *dev)
@@ -2625,6 +2627,7 @@ static int init_egress_acls_root_ns(struct mlx5_core_dev 
*dev)
        for (i--; i >= 0; i--)
                cleanup_root_ns(steering->esw_egress_root_ns[i]);
        kfree(steering->esw_egress_root_ns);
+       steering->esw_egress_root_ns = NULL;
        return err;
 }
 
@@ -2652,6 +2655,7 @@ static int init_ingress_acls_root_ns(struct mlx5_core_dev 
*dev)
        for (i--; i >= 0; i--)
                cleanup_root_ns(steering->esw_ingress_root_ns[i]);
        kfree(steering->esw_ingress_root_ns);
+       steering->esw_ingress_root_ns = NULL;
        return err;
 }
 
-- 
2.21.0

Reply via email to