From: Huazhong Tan Date: Thu, 4 Apr 2019 08:17:56 +0000 (+0800) Subject: net: hns3: check resetting status in hns3_get_stats() X-Git-Tag: v5.0.20~127 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=cee70979bd4c7ec0832b2f4cdd15385e78a791d4;p=thirdparty%2Fkernel%2Fstable.git net: hns3: check resetting status in hns3_get_stats() [ Upstream commit c4e401e5a934bb0798ebbba98e08dab129695eff ] 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 Signed-off-by: Peng Li Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c b/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c index e678b6939da39..36b35c58304b5 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c @@ -482,6 +482,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;