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 2/6] net: hns3: add max order judgement for tx spare buffer
Date: Sat, 26 Mar 2022 17:51:01 +0800 [thread overview]
Message-ID: <20220326095105.54075-3-huangguangbin2@huawei.com> (raw)
In-Reply-To: <20220326095105.54075-1-huangguangbin2@huawei.com>
From: Hao Chen <chenhao288@hisilicon.com>
Add max order judgement for tx spare buffer to avoid triggering
call trace, print related fail information instead, when user
set tx spare buf size to a large value which causes order
exceeding 10.
Fixes: e445f08af2b1 ("net: hns3: add support to set/get tx copybreak buf size via ethtool for hns3 driver")
Signed-off-by: Hao Chen <chenhao288@hisilicon.com>
Signed-off-by: Guangbin Huang <huangguangbin2@huawei.com>
---
drivers/net/ethernet/hisilicon/hns3/hns3_enet.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
index 16137238ddbf..530ba8bef503 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
@@ -1038,6 +1038,12 @@ static void hns3_init_tx_spare_buffer(struct hns3_enet_ring *ring)
return;
order = get_order(alloc_size);
+ if (order >= MAX_ORDER) {
+ if (net_ratelimit())
+ dev_warn(ring_to_dev(ring), "failed to allocate tx spare buffer, exceed to max order\n");
+ return;
+ }
+
tx_spare = devm_kzalloc(ring_to_dev(ring), sizeof(*tx_spare),
GFP_KERNEL);
if (!tx_spare) {
--
2.33.0
next prev parent reply other threads:[~2022-03-26 9:57 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-26 9:50 [PATCH net 0/6] net: hns3: add some fixes for -net Guangbin Huang
2022-03-26 9:51 ` [PATCH net 1/6] net: hns3: fix ethtool tx copybreak buf size indicating not aligned issue Guangbin Huang
2022-03-26 9:51 ` Guangbin Huang [this message]
2022-03-26 9:51 ` [PATCH net 3/6] net: hns3: clean residual vf config after disable sriov Guangbin Huang
2022-03-26 9:51 ` [PATCH net 4/6] net: hns3: add netdev reset check for hns3_set_tunable() Guangbin Huang
2022-03-26 9:51 ` [PATCH net 5/6] net: hns3: add NULL pointer check for hns3_set/get_ringparam() Guangbin Huang
2022-03-26 9:51 ` [PATCH net 6/6] net: hns3: fix phy can not link up when autoneg off and reset Guangbin Huang
2022-03-26 16:20 ` [PATCH net 0/6] net: hns3: add some fixes for -net patchwork-bot+netdevbpf
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=20220326095105.54075-3-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
all inboxes | Powered by JetHome®