net: hns3: fix access null pointer issue when set tx-buf-size as 0
authorHao Chen <chenhao288@hisilicon.com>
Mon, 9 May 2022 07:55:27 +0000 (15:55 +0800)
committerDavid S. Miller <davem@davemloft.net>
Mon, 9 May 2022 13:30:37 +0000 (14:30 +0100)
commit8bacf03f84007ba85fdb95d1f35481cf5760338e
tree2fd4ccb7862027bd417019b0a75c432e7078fb3c
parent9b0044e4dc3445fa5640fbd89addd1401cfc9ae8
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: fdabc8eb0ffa ("net: hns3: add log for setting tx spare buf size")
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>
drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c