Commit 3f52cbfe authored by Jian Shen's avatar Jian Shen Committed by Greg Kroah-Hartman

net: hns3: add protect when handling mac addr list

[ Upstream commit 389775a6 ]

It used netdev->uc and netdev->mc list in function
hns3_recover_hw_addr() and hns3_remove_hw_addr().
We should add protect for them.

Fixes: f05e2109 ("net: hns3: Clear mac vlan table entries when unload driver or function reset")
Signed-off-by: default avatarJian Shen <shenjian15@huawei.com>
Signed-off-by: default avatarPeng Li <lipeng321@huawei.com>
Signed-off-by: default avatarHuazhong Tan <tanhuazhong@huawei.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
parent 9cc0b2b5
...@@ -3774,12 +3774,13 @@ static int hns3_recover_hw_addr(struct net_device *ndev) ...@@ -3774,12 +3774,13 @@ static int hns3_recover_hw_addr(struct net_device *ndev)
struct netdev_hw_addr *ha, *tmp; struct netdev_hw_addr *ha, *tmp;
int ret = 0; int ret = 0;
netif_addr_lock_bh(ndev);
/* go through and sync uc_addr entries to the device */ /* go through and sync uc_addr entries to the device */
list = &ndev->uc; list = &ndev->uc;
list_for_each_entry_safe(ha, tmp, &list->list, list) { list_for_each_entry_safe(ha, tmp, &list->list, list) {
ret = hns3_nic_uc_sync(ndev, ha->addr); ret = hns3_nic_uc_sync(ndev, ha->addr);
if (ret) if (ret)
return ret; goto out;
} }
/* go through and sync mc_addr entries to the device */ /* go through and sync mc_addr entries to the device */
...@@ -3787,9 +3788,11 @@ static int hns3_recover_hw_addr(struct net_device *ndev) ...@@ -3787,9 +3788,11 @@ static int hns3_recover_hw_addr(struct net_device *ndev)
list_for_each_entry_safe(ha, tmp, &list->list, list) { list_for_each_entry_safe(ha, tmp, &list->list, list) {
ret = hns3_nic_mc_sync(ndev, ha->addr); ret = hns3_nic_mc_sync(ndev, ha->addr);
if (ret) if (ret)
return ret; goto out;
} }
out:
netif_addr_unlock_bh(ndev);
return ret; return ret;
} }
...@@ -3800,6 +3803,7 @@ static void hns3_remove_hw_addr(struct net_device *netdev) ...@@ -3800,6 +3803,7 @@ static void hns3_remove_hw_addr(struct net_device *netdev)
hns3_nic_uc_unsync(netdev, netdev->dev_addr); hns3_nic_uc_unsync(netdev, netdev->dev_addr);
netif_addr_lock_bh(netdev);
/* go through and unsync uc_addr entries to the device */ /* go through and unsync uc_addr entries to the device */
list = &netdev->uc; list = &netdev->uc;
list_for_each_entry_safe(ha, tmp, &list->list, list) list_for_each_entry_safe(ha, tmp, &list->list, list)
...@@ -3810,6 +3814,8 @@ static void hns3_remove_hw_addr(struct net_device *netdev) ...@@ -3810,6 +3814,8 @@ static void hns3_remove_hw_addr(struct net_device *netdev)
list_for_each_entry_safe(ha, tmp, &list->list, list) list_for_each_entry_safe(ha, tmp, &list->list, list)
if (ha->refcount > 1) if (ha->refcount > 1)
hns3_nic_mc_unsync(netdev, ha->addr); hns3_nic_mc_unsync(netdev, ha->addr);
netif_addr_unlock_bh(netdev);
} }
static void hns3_clear_tx_ring(struct hns3_enet_ring *ring) static void hns3_clear_tx_ring(struct hns3_enet_ring *ring)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment