net: hns3: add reset checking before set channels
authorJian Shen <shenjian15@huawei.com>
Mon, 29 Jul 2019 02:53:22 +0000 (10:53 +0800)
committerDavid S. Miller <davem@davemloft.net>
Mon, 29 Jul 2019 15:23:40 +0000 (08:23 -0700)
hns3_set_channels() should check the resetting status firstly,
since the device will reinitialize when resetting. If the
reset has not completed, the hns3_set_channels() may access
invalid memory.

Signed-off-by: Jian Shen <shenjian15@huawei.com>
Signed-off-by: Huazhong Tan <tanhuazhong@huawei.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/hisilicon/hns3/hns3_enet.c

index 69f7ef810654c0c408f589e7dd8e8f72ea204b7d..08af782f70b58bdd72e947750111a36b1182096c 100644 (file)
@@ -4378,6 +4378,9 @@ int hns3_set_channels(struct net_device *netdev,
        u16 org_tqp_num;
        int ret;
 
+       if (hns3_nic_resetting(netdev))
+               return -EBUSY;
+
        if (ch->rx_count || ch->tx_count)
                return -EINVAL;