]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
net/mlx5: E-Switch, Fix some error pointer dereferences
authorDan Carpenter <dan.carpenter@oracle.com>
Wed, 3 Jun 2020 17:54:36 +0000 (20:54 +0300)
committerSaeed Mahameed <saeedm@mellanox.com>
Thu, 11 Jun 2020 22:38:08 +0000 (15:38 -0700)
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: 07bab9502641d ("net/mlx5: E-Switch, Refactor eswitch ingress acl codes")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
drivers/net/ethernet/mellanox/mlx5/core/esw/acl/ingress_lgcy.c

index 9bda4fe2eafa7274a85d2bd1b8121509852f58b6..5dc335e621c577898a52d9ee0380275c38bada7f 100644 (file)
@@ -162,10 +162,12 @@ int esw_acl_ingress_lgcy_setup(struct mlx5_eswitch *esw,
 
        if (MLX5_CAP_ESW_INGRESS_ACL(esw->dev, flow_counter)) {
                counter = mlx5_fc_create(esw->dev, false);
-               if (IS_ERR(counter))
+               if (IS_ERR(counter)) {
                        esw_warn(esw->dev,
                                 "vport[%d] configure ingress drop rule counter failed\n",
                                 vport->vport);
+                       counter = NULL;
+               }
                vport->ingress.legacy.drop_counter = counter;
        }
 
@@ -272,7 +274,7 @@ void esw_acl_ingress_lgcy_cleanup(struct mlx5_eswitch *esw,
        esw_acl_ingress_table_destroy(vport);
 
 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);
                vport->ingress.legacy.drop_counter = NULL;
        }