diff options
author | Guojia Liao <liaoguojia@huawei.com> | 2021-08-26 19:21:58 +0800 |
---|---|---|
committer | Jakub Kicinski <kuba@kernel.org> | 2021-08-26 07:24:17 -0700 |
commit | 94391fae82f71c98ecc7716a32611fcca73c74eb (patch) | |
tree | 738c8ebbb8339cf97accc5eace1fd157f767c72a | |
parent | b15c072a9f4a404c09ad589477f4389034742a8b (diff) | |
download | linux-stable-94391fae82f71c98ecc7716a32611fcca73c74eb.tar.gz linux-stable-94391fae82f71c98ecc7716a32611fcca73c74eb.tar.bz2 linux-stable-94391fae82f71c98ecc7716a32611fcca73c74eb.zip |
net: hns3: fix duplicate node in VLAN list
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>
-rw-r--r-- | drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c | 6 |
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 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) |