提交 50ae70f7 编写于 作者: H Hao Chen 提交者: Zheng Zengkai

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

mainline inclusion
from mainline-net-5.17
commit 4d07c593
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I4YXIM
CVE: NA

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=4d07c5936c25

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

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: NHao Chen <chenhao288@hisilicon.com>
Signed-off-by: NGuangbin Huang <huangguangbin2@huawei.com>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
Reviewed-by: NYue Haibing <yuehaibing@huawei.com>
Acked-by: NXie XiuQi <xiexiuqi@huawei.com>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
上级 254bd7e8
......@@ -670,8 +670,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;
}
......@@ -1091,8 +1091,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% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册