From: Petr Machata Date: Mon, 3 Aug 2020 16:11:36 +0000 (+0300) Subject: mlxsw: spectrum_span: On policer_id_base_ref_count, use dec_and_test X-Git-Tag: v5.10.7~1943^2~32^2~5 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=928345c08b72dd175d4eefa24900f09706a9a3b5;p=platform%2Fkernel%2Flinux-rpi.git mlxsw: spectrum_span: On policer_id_base_ref_count, use dec_and_test 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 Reviewed-by: Jiri Pirko Signed-off-by: Ido Schimmel Signed-off-by: David S. Miller --- diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_span.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_span.c index 323eaf9..5c959a9 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_span.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_span.c @@ -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 *