提交 4f6c79e5 编写于 作者: J Jian Shen 提交者: Zheng Zengkai

net: hns3: add check for HNS3_NIC_STATE_INITED in hns3_reset_notify_up_enet()

stable inclusion
from stable-5.10.38
commit 7a476a8a9cb69096ea37c8f71ec3455a4be3c948
bugzilla: 51875
CVE: NA

--------------------------------

[ Upstream commit b4047aac ]

In some cases, the device is not initialized because reset failed.
If another task calls hns3_reset_notify_up_enet() before reset
retry, it will cause an error since uninitialized pointer access.
So add check for HNS3_NIC_STATE_INITED before calling
hns3_nic_net_open() in hns3_reset_notify_up_enet().

Fixes: bb6b94a8 ("net: hns3: Add reset interface implementation in client")
Signed-off-by: NJian Shen <shenjian15@huawei.com>
Signed-off-by: NHuazhong Tan <tanhuazhong@huawei.com>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
Signed-off-by: NSasha Levin <sashal@kernel.org>
Signed-off-by: NChen Jun <chenjun102@huawei.com>
Acked-by: NWeilong Chen <chenweilong@huawei.com>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
上级 8ffc16bf
......@@ -4426,6 +4426,11 @@ static int hns3_reset_notify_up_enet(struct hnae3_handle *handle)
struct hns3_nic_priv *priv = netdev_priv(kinfo->netdev);
int ret = 0;
if (!test_bit(HNS3_NIC_STATE_INITED, &priv->state)) {
netdev_err(kinfo->netdev, "device is not initialized yet\n");
return -EFAULT;
}
clear_bit(HNS3_NIC_STATE_RESETTING, &priv->state);
if (netif_running(kinfo->netdev)) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册