From e9a20c30d6388c4215982b134819aed89b0d4e4f Mon Sep 17 00:00:00 2001 From: Huazhong Tan Date: Thu, 25 Apr 2019 16:19:54 +0800 Subject: [PATCH] net: hns3: check resetting status when doing VLAN ops driver inclusion category: bugfix bugzilla: NA CVE: NA The VLAN ops should check the resetting status firstly, since the device will be reinitialized when resetting. If the reset has not completed, the VLAN ops may access invalid memory. And this checking can make it return as soon as possible. Feature or Bugfix:Bugfix Signed-off-by: Huazhong Tan Reviewed-by: shenjian Reviewed-by: Xie XiuQi Signed-off-by: Yang Yingliang --- drivers/net/ethernet/hisilicon/hns3/hns3_enet.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c index 9d46b2c8c2e7..c8a361a51cb4 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c @@ -1641,6 +1641,9 @@ static int hns3_vlan_rx_add_vid(struct net_device *netdev, struct hnae3_handle *h = hns3_get_handle(netdev); int ret = -EIO; + if (hns3_nic_resetting(netdev)) + return -EBUSY; + if (h->ae_algo->ops->set_vlan_filter) ret = h->ae_algo->ops->set_vlan_filter(h, proto, vid, false); @@ -1653,6 +1656,9 @@ static int hns3_vlan_rx_kill_vid(struct net_device *netdev, struct hnae3_handle *h = hns3_get_handle(netdev); int ret = -EIO; + if (hns3_nic_resetting(netdev)) + return -EBUSY; + if (h->ae_algo->ops->set_vlan_filter) ret = h->ae_algo->ops->set_vlan_filter(h, proto, vid, true); @@ -1674,6 +1680,9 @@ static int hns3_ndo_set_vf_vlan(struct net_device *netdev, int vf, u16 vlan, __be16 vlan_proto = htons(ETH_P_8021Q); #endif + if (hns3_nic_resetting(netdev)) + return -EBUSY; + if (h->ae_algo->ops->set_vf_vlan_filter) ret = h->ae_algo->ops->set_vf_vlan_filter(h, vf, vlan, qos, vlan_proto); -- GitLab