Skip to content

Commit 09a9297

Browse files
Dan CarpenterSaeed Mahameed
authored andcommitted
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: 07bab95 ("net/mlx5: E-Switch, Refactor eswitch ingress acl codes") Signed-off-by: Dan Carpenter <[email protected]> Signed-off-by: Saeed Mahameed <[email protected]>
1 parent 17e73d4 commit 09a9297

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

drivers/net/ethernet/mellanox/mlx5/core/esw/acl/ingress_lgcy.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,10 +162,12 @@ int esw_acl_ingress_lgcy_setup(struct mlx5_eswitch *esw,
162162

163163
if (MLX5_CAP_ESW_INGRESS_ACL(esw->dev, flow_counter)) {
164164
counter = mlx5_fc_create(esw->dev, false);
165-
if (IS_ERR(counter))
165+
if (IS_ERR(counter)) {
166166
esw_warn(esw->dev,
167167
"vport[%d] configure ingress drop rule counter failed\n",
168168
vport->vport);
169+
counter = NULL;
170+
}
169171
vport->ingress.legacy.drop_counter = counter;
170172
}
171173

@@ -272,7 +274,7 @@ void esw_acl_ingress_lgcy_cleanup(struct mlx5_eswitch *esw,
272274
esw_acl_ingress_table_destroy(vport);
273275

274276
clean_drop_counter:
275-
if (!IS_ERR_OR_NULL(vport->ingress.legacy.drop_counter)) {
277+
if (vport->ingress.legacy.drop_counter) {
276278
mlx5_fc_destroy(esw->dev, vport->ingress.legacy.drop_counter);
277279
vport->ingress.legacy.drop_counter = NULL;
278280
}

0 commit comments

Comments
 (0)