summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuojia Liao <liaoguojia@huawei.com>2021-08-26 19:21:58 +0800
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2021-09-03 10:09:25 +0200
commite834ca7c7924bf1ae19228035574dae29ad61e38 (patch)
treeb447d909940aebc01b059d30de5dc71f21742d40
parent5931ec35e992d8343ae6fdbce2206196289b0926 (diff)
downloadlinux-stable-e834ca7c7924bf1ae19228035574dae29ad61e38.tar.gz
linux-stable-e834ca7c7924bf1ae19228035574dae29ad61e38.tar.bz2
linux-stable-e834ca7c7924bf1ae19228035574dae29ad61e38.zip
net: hns3: fix duplicate node in VLAN list
[ Upstream commit 94391fae82f71c98ecc7716a32611fcca73c74eb ] 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> Signed-off-by: Jakub Kicinski <kuba@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
-rw-r--r--drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
index c48c845472ca..2261de5caf86 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
@@ -8792,7 +8792,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)