51 lines
1.8 KiB
Diff
51 lines
1.8 KiB
Diff
From e01061aeb9fc278e1c9f0b2c6d667a7edaea41ec Mon Sep 17 00:00:00 2001
|
|
From: Hao Chen <chenhao288@hisilicon.com>
|
|
Date: Sat, 26 Mar 2022 17:51:01 +0800
|
|
Subject: [PATCH 271/283] net: hns3: add max order judgement for tx spare
|
|
buffer
|
|
|
|
mainline inclusion
|
|
from mainline-v5.18-rc1
|
|
commit a89cbb16995bf15582e0d1bdb922ad1a54a2fa8c
|
|
category: bugfix
|
|
bugzilla: https://gitee.com/src-openeuler/kernel/issues/I8EN49
|
|
|
|
Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=a89cbb16995bf15582e0d1bdb922ad1a54a2fa8c
|
|
|
|
--------------------------------
|
|
|
|
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>
|
|
Signed-off-by: David S. Miller <davem@davemloft.net>
|
|
Signed-off-by: Xiaodong Li <lixiaodong67@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 f9dacf01ddd6..5c723c532289 100644
|
|
--- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
|
|
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
|
|
@@ -746,6 +746,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.34.1
|
|
|