mlxsw: spectrum_acl_tcam: Fix NULL pointer dereference in error path
[platform/kernel/linux-starfive.git] / drivers / net / ethernet / mellanox / mlxsw / spectrum_acl_tcam.c
index d50786b..7d1e911 100644 (file)
@@ -681,13 +681,13 @@ static void
 mlxsw_sp_acl_tcam_region_destroy(struct mlxsw_sp *mlxsw_sp,
                                 struct mlxsw_sp_acl_tcam_region *region)
 {
+       struct mlxsw_sp_acl_tcam *tcam = mlxsw_sp_acl_to_tcam(mlxsw_sp->acl);
        const struct mlxsw_sp_acl_tcam_ops *ops = mlxsw_sp->acl_tcam_ops;
 
        ops->region_fini(mlxsw_sp, region->priv);
        mlxsw_sp_acl_tcam_region_disable(mlxsw_sp, region);
        mlxsw_sp_acl_tcam_region_free(mlxsw_sp, region);
-       mlxsw_sp_acl_tcam_region_id_put(region->group->tcam,
-                                       region->id);
+       mlxsw_sp_acl_tcam_region_id_put(tcam, region->id);
        kfree(region);
 }