Commit 09a92975 authored by Dan Carpenter's avatar Dan Carpenter Committed by Saeed Mahameed

net/mlx5: E-Switch, Fix some error pointer dereferences

We can't leave "counter" set to an error pointer.  Otherwise either it
will lead to an error pointer dereference later in the function or it
leads to an error pointer dereference when we call mlx5_fc_destroy().

Fixes: 07bab950 ("net/mlx5: E-Switch, Refactor eswitch ingress acl codes")
Signed-off-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: default avatarSaeed Mahameed <saeedm@mellanox.com>
parent 17e73d47
...@@ -162,10 +162,12 @@ int esw_acl_ingress_lgcy_setup(struct mlx5_eswitch *esw, ...@@ -162,10 +162,12 @@ int esw_acl_ingress_lgcy_setup(struct mlx5_eswitch *esw,
if (MLX5_CAP_ESW_INGRESS_ACL(esw->dev, flow_counter)) { if (MLX5_CAP_ESW_INGRESS_ACL(esw->dev, flow_counter)) {
counter = mlx5_fc_create(esw->dev, false); counter = mlx5_fc_create(esw->dev, false);
if (IS_ERR(counter)) if (IS_ERR(counter)) {
esw_warn(esw->dev, esw_warn(esw->dev,
"vport[%d] configure ingress drop rule counter failed\n", "vport[%d] configure ingress drop rule counter failed\n",
vport->vport); vport->vport);
counter = NULL;
}
vport->ingress.legacy.drop_counter = counter; vport->ingress.legacy.drop_counter = counter;
} }
...@@ -272,7 +274,7 @@ void esw_acl_ingress_lgcy_cleanup(struct mlx5_eswitch *esw, ...@@ -272,7 +274,7 @@ void esw_acl_ingress_lgcy_cleanup(struct mlx5_eswitch *esw,
esw_acl_ingress_table_destroy(vport); esw_acl_ingress_table_destroy(vport);
clean_drop_counter: clean_drop_counter:
if (!IS_ERR_OR_NULL(vport->ingress.legacy.drop_counter)) { if (vport->ingress.legacy.drop_counter) {
mlx5_fc_destroy(esw->dev, vport->ingress.legacy.drop_counter); mlx5_fc_destroy(esw->dev, vport->ingress.legacy.drop_counter);
vport->ingress.legacy.drop_counter = NULL; vport->ingress.legacy.drop_counter = NULL;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment