kernel/patches/0634-net-hns3-add-netdev-reset-check-for-hns3_set_tunable.patch
2023-11-17 14:19:46 +08:00

60 lines
2.1 KiB
Diff

From d1032c11f5df2a5e1fa2f6868cc40f6b944747db Mon Sep 17 00:00:00 2001
From: Hao Chen <chenhao288@hisilicon.com>
Date: Sat, 26 Mar 2022 17:51:03 +0800
Subject: [PATCH 273/283] net: hns3: add netdev reset check for
hns3_set_tunable()
mainline inclusion
from mainline-v5.18
commit f5cd60169f981ca737c9e49c446506dfafc90a35
category: bugfix
bugzilla: https://gitee.com/src-openeuler/kernel/issues/I8EN49
Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=f5cd60169f981ca737c9e49c446506dfafc90a35
--------------------------------
When pci device reset failed, it does uninit operation and priv->ring
is NULL, it causes accessing NULL pointer error.
Add netdev reset check for hns3_set_tunable() to fix it.
Fixes: 99f6b5fb5f63 ("net: hns3: use bounce buffer when rx page can not be reused")
Signed-off-by: Hao Chen <chenhao288@hisilicon.com>
Signed-off-by: Guangbin Huang <huangguangbin2@huawei.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Xiaodong Li <lixiaodong67@huawei.com>
---
drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c b/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c
index 8ac71b53ddf0..21675ff52380 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c
@@ -1827,9 +1827,6 @@ static int hns3_set_tx_spare_buf_size(struct net_device *netdev,
struct hnae3_handle *h = priv->ae_handle;
int ret;
- if (hns3_nic_resetting(netdev))
- return -EBUSY;
-
h->kinfo.tx_spare_buf_size = data;
ret = hns3_reset_notify(h, HNAE3_DOWN_CLIENT);
@@ -1860,6 +1857,11 @@ static int hns3_set_tunable(struct net_device *netdev,
struct hnae3_handle *h = priv->ae_handle;
int i, ret = 0;
+ if (hns3_nic_resetting(netdev) || !priv->ring) {
+ netdev_err(netdev, "failed to set tunable value, dev resetting!");
+ return -EBUSY;
+ }
+
switch (tuna->id) {
case ETHTOOL_TX_COPYBREAK:
priv->tx_copybreak = *(u32 *)data;
--
2.34.1