Skip to content

Commit

Permalink
net: hns3: add netdev reset check for hns3_set_tunable()
Browse files Browse the repository at this point in the history
[ Upstream commit f5cd601 ]

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: 99f6b5f ("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: Sasha Levin <sashal@kernel.org>
  • Loading branch information
Hao Chen authored and gregkh committed Apr 8, 2022
1 parent 81d4701 commit 1ff44dd
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c
Expand Up @@ -1764,9 +1764,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);
Expand Down Expand Up @@ -1797,6 +1794,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;
Expand Down

0 comments on commit 1ff44dd

Please sign in to comment.