All of lore.kernel.org
 help / color / mirror / Atom feed
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>
Subject: [PATCH net 4/7] net: hns3: fix duplicate node in VLAN list
Date: Thu, 26 Aug 2021 19:21:58 +0800	[thread overview]
Message-ID: <1629976921-43438-5-git-send-email-huangguangbin2@huawei.com> (raw)
In-Reply-To: <1629976921-43438-1-git-send-email-huangguangbin2@huawei.com>

From: Guojia Liao <liaoguojia@huawei.com>

VLAN list should not be added duplicate VLAN node, otherwise it would
cause "add failed" when restore VLAN from VLAN list, so this patch adds
VLAN ID check before adding node into VLAN list.

Fixes: c6075b193462 ("net: hns3: Record VF vlan tables")
Signed-off-by: Guojia Liao <liaoguojia@huawei.com>
Signed-off-by: Guangbin Huang <huangguangbin2@huawei.com>
---
 drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
index 78408136f253..1d0fa966e55a 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
@@ -10073,7 +10073,11 @@ static int hclge_init_vlan_config(struct hclge_dev *hdev)
 static void hclge_add_vport_vlan_table(struct hclge_vport *vport, u16 vlan_id,
 				       bool writen_to_tbl)
 {
-	struct hclge_vport_vlan_cfg *vlan;
+	struct hclge_vport_vlan_cfg *vlan, *tmp;
+
+	list_for_each_entry_safe(vlan, tmp, &vport->vlan_list, node)
+		if (vlan->vlan_id == vlan_id)
+			return;
 
 	vlan = kzalloc(sizeof(*vlan), GFP_KERNEL);
 	if (!vlan)
-- 
2.8.1


  parent reply	other threads:[~2021-08-26 11:26 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-26 11:21 [PATCH net 0/7] net: hns3: add some fixes for -net Guangbin Huang
2021-08-26 11:21 ` [PATCH net 1/7] net: hns3: clear hardware resource when loading driver Guangbin Huang
2021-08-26 11:21 ` [PATCH net 2/7] net: hns3: add waiting time before cmdq memory is released Guangbin Huang
2021-08-26 11:21 ` [PATCH net 3/7] net: hns3: fix speed unknown issue in bond 4 Guangbin Huang
2021-08-26 11:21 ` Guangbin Huang [this message]
2021-08-26 11:21 ` [PATCH net 5/7] net: hns3: change the method of getting cmd index in debugfs Guangbin Huang
2021-08-26 11:22 ` [PATCH net 6/7] net: hns3: fix GRO configuration error after reset Guangbin Huang
2021-08-26 11:22 ` [PATCH net 7/7] net: hns3: fix get wrong pfc_en when query PFC configuration Guangbin Huang
2021-08-26 15:50 ` [PATCH net 0/7] 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=1629976921-43438-5-git-send-email-huangguangbin2@huawei.com \
    --to=huangguangbin2@huawei.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.