bnxt_en: Fix race when modifying pause settings.
authorVasundhara Volam <vasundhara-v.volam@broadcom.com>
Sun, 12 Jul 2020 00:48:23 +0000 (20:48 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 29 Jul 2020 05:42:53 +0000 (07:42 +0200)
[ Upstream commit 163e9ef63641a02de4c95cd921577265c52e1ce2 ]

The driver was modified to not rely on rtnl lock to protect link
settings about 2 years ago.  The pause setting was missed when
making that change.  Fix it by acquiring link_lock mutex before
calling bnxt_hwrm_set_pause().

Fixes: e2dc9b6e38fa ("bnxt_en: Don't use rtnl lock to protect link change logic in workqueue.")
Signed-off-by: Vasundhara Volam <vasundhara-v.volam@broadcom.com>
Reviewed-by: Edwin Peer <edwin.peer@broadcom.com>
Signed-off-by: Michael Chan <michael.chan@broadcom.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c

index 3c78cd1cdd6fb7ce5caddabf063816fda069aaa6..6edbbfc1709a24cab042eec3a27e5dfa83a38793 100644 (file)
@@ -1287,8 +1287,11 @@ static int bnxt_set_pauseparam(struct net_device *dev,
        if (epause->tx_pause)
                link_info->req_flow_ctrl |= BNXT_LINK_PAUSE_TX;
 
-       if (netif_running(dev))
+       if (netif_running(dev)) {
+               mutex_lock(&bp->link_lock);
                rc = bnxt_hwrm_set_pause(bp);
+               mutex_unlock(&bp->link_lock);
+       }
        return rc;
 }