提交 a4fe9b6d 编写于 作者: H Hao Chen 提交者: David S. Miller

net: hns3: fix access null pointer issue when set tx-buf-size as 0

When set tx-buf-size as 0 by ethtool, hns3_init_tx_spare_buffer()
will return directly and priv->ring->tx_spare->len is uninitialized,
then print function access priv->ring->tx_spare->len will cause
this issue.

When set tx-buf-size as 0 by ethtool, the print function will
print 0 directly and not access priv->ring->tx_spare->len.

Fixes: 2373b35c ("net: hns3: add log for setting tx spare buf size")
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>
上级 1728c056
......@@ -1915,8 +1915,11 @@ static int hns3_set_tunable(struct net_device *netdev,
return ret;
}
netdev_info(netdev, "the active tx spare buf size is %u, due to page order\n",
priv->ring->tx_spare->len);
if (!priv->ring->tx_spare)
netdev_info(netdev, "the active tx spare buf size is 0, disable tx spare buffer\n");
else
netdev_info(netdev, "the active tx spare buf size is %u, due to page order\n",
priv->ring->tx_spare->len);
break;
default:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册
新手
引导
客服 返回
顶部