]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
net: hns3: check resetting status in hns3_get_stats()
authorHuazhong Tan <tanhuazhong@huawei.com>
Thu, 4 Apr 2019 08:17:56 +0000 (16:17 +0800)
committerDavid S. Miller <davem@davemloft.net>
Thu, 4 Apr 2019 17:20:39 +0000 (10:20 -0700)
hns3_get_stats() should check the resetting status firstly,
since the device will be reinitialized when resetting. If the
reset has not completed, the hns3_get_stats() may access
invalid memory.

Signed-off-by: Huazhong Tan <tanhuazhong@huawei.com>
Signed-off-by: Peng Li <lipeng321@huawei.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c

index fc82d0e115464ae15f6b271389de74174757d5f0..59ef272297abb5635ea5fba194bdebe1d7576c12 100644 (file)
@@ -483,6 +483,11 @@ static void hns3_get_stats(struct net_device *netdev,
        struct hnae3_handle *h = hns3_get_handle(netdev);
        u64 *p = data;
 
+       if (hns3_nic_resetting(netdev)) {
+               netdev_err(netdev, "dev resetting, could not get stats\n");
+               return;
+       }
+
        if (!h->ae_algo->ops->get_stats || !h->ae_algo->ops->update_stats) {
                netdev_err(netdev, "could not get any statistics\n");
                return;