From: Guangbin Huang <huangguangbin2@huawei.com>
To: <davem@davemloft.net>, <kuba@kernel.org>
Cc: <netdev@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
<lipeng321@huawei.com>, <huangguangbin2@huawei.com>,
<chenhao288@hisilicon.com>
Subject: [PATCH net-next 1/5] net: hns3: fix access null pointer issue when set tx-buf-size as 0
Date: Thu, 5 May 2022 20:44:40 +0800 [thread overview]
Message-ID: <20220505124444.2233-2-huangguangbin2@huawei.com> (raw)
In-Reply-To: <20220505124444.2233-1-huangguangbin2@huawei.com>
From: Hao Chen <chenhao288@hisilicon.com>
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: 2373b35c24ff ("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>
---
drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c b/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c
index 1db8a86f046d..6d20974519fe 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c
@@ -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:
--
2.33.0
next prev parent reply other threads:[~2022-05-05 12:50 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-05 12:44 [PATCH net-next 0/5] net: hns3: updates for -next Guangbin Huang
2022-05-05 12:44 ` Guangbin Huang [this message]
2022-05-05 12:44 ` [PATCH net-next 2/5] net: hns3: remove the affinity settings of vector0 Guangbin Huang
2022-05-05 12:44 ` [PATCH net-next 3/5] net: hns3: add byte order conversion for PF to VF mailbox message Guangbin Huang
2022-05-06 1:47 ` Jakub Kicinski
2022-05-06 12:10 ` huangguangbin (A)
2022-05-05 12:44 ` [PATCH net-next 4/5] net: hns3: add byte order conversion for VF to PF " Guangbin Huang
2022-05-05 12:44 ` [PATCH net-next 5/5] net: hns3: add query vf ring and vector map relation Guangbin Huang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220505124444.2233-2-huangguangbin2@huawei.com \
--to=huangguangbin2@huawei.com \
--cc=chenhao288@hisilicon.com \
--cc=davem@davemloft.net \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lipeng321@huawei.com \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).