Skip to content

Commit

Permalink
mlxsw: spectrum_span: On policer_id_base_ref_count, use dec_and_test
Browse files Browse the repository at this point in the history
When unsetting policer base, the SPAN code currently uses refcount_dec().
However that function splats when the counter reaches zero, because
reaching zero without actually testing is in general indicative of a
missing cleanup. There is no cleanup to be done here, but nonetheless, use
refcount_dec_and_test() as required.

Signed-off-by: Petr Machata <petrm@mellanox.com>
Reviewed-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: Ido Schimmel <idosch@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Petr Machata authored and David S. Miller committed Aug 4, 2020
1 parent 76ba292 commit 928345c
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion drivers/net/ethernet/mellanox/mlxsw/spectrum_span.c
Original file line number Diff line number Diff line change
Expand Up @@ -837,7 +837,8 @@ static int mlxsw_sp_span_policer_id_base_set(struct mlxsw_sp_span *span,

static void mlxsw_sp_span_policer_id_base_unset(struct mlxsw_sp_span *span)
{
refcount_dec(&span->policer_id_base_ref_count);
if (refcount_dec_and_test(&span->policer_id_base_ref_count))
span->policer_id_base = 0;
}

static struct mlxsw_sp_span_entry *
Expand Down

0 comments on commit 928345c

Please sign in to comment.