Commit 4d07c593 authored by Hao Chen's avatar Hao Chen Committed by David S. Miller

net: hns3: add NULL pointer check for hns3_set/get_ringparam()

When pci devices init failed and haven't reinit, priv->ring is
NULL and hns3_set/get_ringparam() will access priv->ring. it
causes call trace.

So, add NULL pointer check for hns3_set/get_ringparam() to
avoid this situation.

Fixes: 5668abda ("net: hns3: add support for set_ringparam")
Signed-off-by: default avatarHao Chen <chenhao288@hisilicon.com>
Signed-off-by: default avatarGuangbin Huang <huangguangbin2@huawei.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent f5cd6016
......@@ -653,8 +653,8 @@ static void hns3_get_ringparam(struct net_device *netdev,
struct hnae3_handle *h = priv->ae_handle;
int rx_queue_index = h->kinfo.num_tqps;
if (hns3_nic_resetting(netdev)) {
netdev_err(netdev, "dev resetting!");
if (hns3_nic_resetting(netdev) || !priv->ring) {
netdev_err(netdev, "failed to get ringparam value, due to dev resetting or uninited\n");
return;
}
......@@ -1074,8 +1074,14 @@ static int hns3_check_ringparam(struct net_device *ndev,
{
#define RX_BUF_LEN_2K 2048
#define RX_BUF_LEN_4K 4096
if (hns3_nic_resetting(ndev))
struct hns3_nic_priv *priv = netdev_priv(ndev);
if (hns3_nic_resetting(ndev) || !priv->ring) {
netdev_err(ndev, "failed to set ringparam value, due to dev resetting or uninited\n");
return -EBUSY;
}
if (param->rx_mini_pending || param->rx_jumbo_pending)
return -EINVAL;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment