mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Wentao Liang <vulab@iscas.ac.cn>
To: shenjian15@huawei.com, salil.mehta@huawei.com,
	shaojijie@huawei.com, andrew+netdev@lunn.ch, davem@davemloft.net,
	edumazet@google.com, kuba@kernel.org, pabeni@redhat.com
Cc: horms@kernel.org, lanhao@huawei.com, wangpeiyang1@huawei.com,
	rosenp@gmail.com, liuyonglong@huawei.com, netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org, Wentao Liang <vulab@iscas.ac.cn>,
	stable@vger.kernel.org
Subject: [PATCH] net: hns3: Add error handling for VLAN filter hardware configuration
Date: Sat, 17 May 2025 22:15:14 +0800	[thread overview]
Message-ID: <20250517141514.800-1-vulab@iscas.ac.cn> (raw)

The hclge_rm_vport_vlan_table() calls hclge_set_vlan_filter_hw() but does
not check the return value. This could lead to execution with potentially
invalid data. A proper implementation can be found in
hclge_add_vport_all_vlan_table().

Add error handling after calling hclge_set_vlan_filter_hw(). If
hclge_set_vlan_filter_hw() fails, log an error message via dev_err() and
return.

Fixes: c6075b193462 ("net: hns3: Record VF vlan tables")
Cc: stable@vger.kernel.org # v5.1
Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
---
 .../hisilicon/hns3/hns3pf/hclge_main.c        | 20 +++++++++++++------
 1 file changed, 14 insertions(+), 6 deletions(-)

diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
index db7845009252..5ab4c7f63766 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
@@ -10141,15 +10141,23 @@ static void hclge_rm_vport_vlan_table(struct hclge_vport *vport, u16 vlan_id,
 {
 	struct hclge_vport_vlan_cfg *vlan, *tmp;
 	struct hclge_dev *hdev = vport->back;
+	int ret;
 
 	list_for_each_entry_safe(vlan, tmp, &vport->vlan_list, node) {
 		if (vlan->vlan_id == vlan_id) {
-			if (is_write_tbl && vlan->hd_tbl_status)
-				hclge_set_vlan_filter_hw(hdev,
-							 htons(ETH_P_8021Q),
-							 vport->vport_id,
-							 vlan_id,
-							 true);
+			if (is_write_tbl && vlan->hd_tbl_status) {
+				ret = hclge_set_vlan_filter_hw(hdev,
+							       htons(ETH_P_8021Q),
+							       vport->vport_id,
+							       vlan_id,
+							       true);
+				if (ret) {
+					dev_err(&hdev->pdev->dev,
+						"restore vport vlan list failed, ret=%d\n",
+						ret);
+					return;
+				}
+			}
 
 			list_del(&vlan->node);
 			kfree(vlan);
-- 
2.42.0.windows.2


             reply	other threads:[~2025-05-17 14:16 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-05-17 14:15 Wentao Liang [this message]
2025-05-19 15:30 ` Jijie Shao
     [not found]   ` <682BD774.007007.29338@cstnet.cn>
2025-05-20 14:37     ` [PATCH] net: hns3: Add error handling for VLAN filter hardwareconfiguration Simon Horman
2025-05-21  2:43     ` Jijie Shao

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=20250517141514.800-1-vulab@iscas.ac.cn \
    --to=vulab@iscas.ac.cn \
    --cc=andrew+netdev@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=horms@kernel.org \
    --cc=kuba@kernel.org \
    --cc=lanhao@huawei.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=liuyonglong@huawei.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=rosenp@gmail.com \
    --cc=salil.mehta@huawei.com \
    --cc=shaojijie@huawei.com \
    --cc=shenjian15@huawei.com \
    --cc=stable@vger.kernel.org \
    --cc=wangpeiyang1@huawei.com \
    /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®