Skip to content

Commit 3456901

Browse files
paravmellanoxgregkh
authored andcommitted
net/mlx5: Avoid double free in fs init error unwinding path
[ Upstream commit 9414277 ] 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: 9b93ab9 ("net/mlx5: Separate ingress/egress namespaces for each vport") Fixes: 40c3eebb49e51 ("net/mlx5: Add support in RDMA RX steering") Signed-off-by: Parav Pandit <parav@mellanox.com> Reviewed-by: Mark Bloch <markb@mellanox.com> Signed-off-by: Saeed Mahameed <saeedm@mellanox.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 7428c3f commit 3456901

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

  • drivers/net/ethernet/mellanox/mlx5/core

‎drivers/net/ethernet/mellanox/mlx5/core/fs_core.c‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2429,6 +2429,7 @@ static void cleanup_egress_acls_root_ns(struct mlx5_core_dev *dev)
24292429
cleanup_root_ns(steering->esw_egress_root_ns[i]);
24302430

24312431
kfree(steering->esw_egress_root_ns);
2432+
steering->esw_egress_root_ns = NULL;
24322433
}
24332434

24342435
static void cleanup_ingress_acls_root_ns(struct mlx5_core_dev *dev)
@@ -2443,6 +2444,7 @@ static void cleanup_ingress_acls_root_ns(struct mlx5_core_dev *dev)
24432444
cleanup_root_ns(steering->esw_ingress_root_ns[i]);
24442445

24452446
kfree(steering->esw_ingress_root_ns);
2447+
steering->esw_ingress_root_ns = NULL;
24462448
}
24472449

24482450
void mlx5_cleanup_fs(struct mlx5_core_dev *dev)
@@ -2611,6 +2613,7 @@ static int init_egress_acls_root_ns(struct mlx5_core_dev *dev)
26112613
for (i--; i >= 0; i--)
26122614
cleanup_root_ns(steering->esw_egress_root_ns[i]);
26132615
kfree(steering->esw_egress_root_ns);
2616+
steering->esw_egress_root_ns = NULL;
26142617
return err;
26152618
}
26162619

@@ -2638,6 +2641,7 @@ static int init_ingress_acls_root_ns(struct mlx5_core_dev *dev)
26382641
for (i--; i >= 0; i--)
26392642
cleanup_root_ns(steering->esw_ingress_root_ns[i]);
26402643
kfree(steering->esw_ingress_root_ns);
2644+
steering->esw_ingress_root_ns = NULL;
26412645
return err;
26422646
}
26432647

0 commit comments

Comments
 (0)