aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c
diff options
context:
space:
mode:
authorHuazhong Tan <tanhuazhong@huawei.com>2019-04-04 16:17:56 +0800
committerDavid S. Miller <davem@davemloft.net>2019-04-04 10:20:39 -0700
commitc4e401e5a934bb0798ebbba98e08dab129695eff (patch)
tree6c96e297ecdcd0b6ee54123c68125cceb3eac243 /drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c
parentnet: hns3: add protect when handling mac addr list (diff)
downloadlinux-dev-c4e401e5a934bb0798ebbba98e08dab129695eff.tar.xz
linux-dev-c4e401e5a934bb0798ebbba98e08dab129695eff.zip
net: hns3: check resetting status in hns3_get_stats()
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>
Diffstat (limited to '')
-rw-r--r--drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c b/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c
index fc82d0e11546..59ef272297ab 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c
@@ -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;