mlxsw: spectrum_router: Fix rif counter freeing routine
authorArkadi Sharshevsky <arkadis@mellanox.com>
Thu, 18 May 2017 07:18:53 +0000 (09:18 +0200)
committerDavid S. Miller <davem@davemloft.net>
Thu, 18 May 2017 15:04:00 +0000 (11:04 -0400)
During rif counter freeing the counter index can be invalid. Add check
of validity before freeing the counter.

Fixes: e0c0afd8aa4e ("mlxsw: spectrum: Support for counters on router interfaces")
Signed-off-by: Arkadi Sharshevsky <arkadis@mellanox.com>
Signed-off-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c

index 33cec1cc164259ad9d7dd022a811e957447a61ff..9f89c4137d2137f78bcda8f79a918b8db61a5189 100644 (file)
@@ -206,6 +206,9 @@ void mlxsw_sp_rif_counter_free(struct mlxsw_sp *mlxsw_sp,
 {
        unsigned int *p_counter_index;
 
+       if (!mlxsw_sp_rif_counter_valid_get(rif, dir))
+               return;
+
        p_counter_index = mlxsw_sp_rif_p_counter_get(rif, dir);
        if (WARN_ON(!p_counter_index))
                return;