net/sfc: fix MAC stats lock in xstats query by ID
authorIvan Ilchenko <ivan.ilchenko@oktetlabs.ru>
Fri, 23 Jul 2021 13:15:05 +0000 (16:15 +0300)
committerThomas Monjalon <thomas@monjalon.net>
Fri, 23 Jul 2021 20:58:30 +0000 (22:58 +0200)
Add MAC stats lock in xstats_get_by_id() callback before reading
number of supported MAC stats.

Fixes: 73280c1e4ff ("net/sfc: support xstats retrieval by ID")
Cc: stable@dpdk.org
Signed-off-by: Ivan Ilchenko <ivan.ilchenko@oktetlabs.ru>
Signed-off-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
Reviewed-by: Andy Moreton <amoreton@xilinx.com>
drivers/net/sfc/sfc_ethdev.c

index 88896db..d4ac61f 100644 (file)
@@ -789,12 +789,14 @@ sfc_xstats_get_by_id(struct rte_eth_dev *dev, const uint64_t *ids,
        int ret;
        int rc;
 
-       if (unlikely(values == NULL) ||
-           unlikely((ids == NULL) && (n < port->mac_stats_nb_supported)))
-               return port->mac_stats_nb_supported;
-
        rte_spinlock_lock(&port->mac_stats_lock);
 
+       if (unlikely(values == NULL) ||
+           unlikely(ids == NULL && n < port->mac_stats_nb_supported)) {
+               ret = port->mac_stats_nb_supported;
+               goto unlock;
+       }
+
        rc = sfc_port_update_mac_stats(sa);
        if (rc != 0) {
                SFC_ASSERT(rc > 0);