From 423b5d8863b5da1b209c04578aaba69bb38b0cb2 Mon Sep 17 00:00:00 2001 From: Guojia Liao Date: Fri, 11 Oct 2019 21:12:21 +0800 Subject: [PATCH] net: hns3: fix incorrect return value when updating vlan table driver inclusion category: bugfix bugzilla: NA CVE: NA When updating vlan filter for port base vlan, it could be fail in some unexpect case. However, the original codes didn't not deal with those case and just return a retult as 'OK'. This patch fix it. Fixes: 073cb1f5614e ("net: hns3: fix set port base vlan issue") Feature or Bugfix:Bugfix Signed-off-by: Guojia Liao Reviewed-by: lipeng Reviewed-by: Yunsheng Lin Signed-off-by: Yang Yingliang --- .../hisilicon/hns3/hns3pf/hclge_main.c | 45 +++++++++---------- 1 file changed, 22 insertions(+), 23 deletions(-) diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c index 34c9d8882db7..803140f949e1 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c @@ -62,10 +62,6 @@ static int hclge_init_vlan_config(struct hclge_dev *hdev); static void hclge_sync_vlan_filter(struct hclge_dev *hdev); static int hclge_reset_ae_dev(struct hnae3_ae_dev *ae_dev); static bool hclge_get_hw_reset_stat(struct hnae3_handle *handle); -static void hclge_add_vport_vlan_table(struct hclge_vport *vport, u16 vlan_id, - bool writen_to_tbl); -static void hclge_rm_vport_vlan_table(struct hclge_vport *vport, u16 vlan_id, - bool is_write_tbl); static void hclge_rfs_filter_expire(struct hclge_dev *hdev); static void hclge_clear_arfs_rules(struct hnae3_handle *handle); static int hclge_set_default_loopback(struct hclge_dev *hdev); @@ -8233,21 +8229,28 @@ static void hclge_add_vport_vlan_table(struct hclge_vport *vport, u16 vlan_id, list_add_tail(&vlan->node, &vport->vlan_list); } -static void hclge_add_vport_all_vlan_table(struct hclge_vport *vport) +static int hclge_add_vport_all_vlan_table(struct hclge_vport *vport) { 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->hd_tbl_status) - hclge_set_vlan_filter_hw(hdev, - htons(ETH_P_8021Q), - vport->vport_id, - vlan->vlan_id, - false); - + if (!vlan->hd_tbl_status) { + ret = hclge_set_vlan_filter_hw(hdev, htons(ETH_P_8021Q), + vport->vport_id, + vlan->vlan_id, false); + if (ret) { + dev_err(&hdev->pdev->dev, + "restore vport vlan list failed, ret=%d\n", + ret); + return ret; + } + } vlan->hd_tbl_status = true; } + + return 0; } static void hclge_rm_vport_vlan_table(struct hclge_vport *vport, u16 vlan_id, @@ -8378,19 +8381,15 @@ static int hclge_update_vlan_filter_entries(struct hclge_vport *vport, vport->vport_id, new_info->vlan_tag, false); + } - } else { - ret = hclge_set_vlan_filter_hw(hdev, - htons(old_info->vlan_proto), - vport->vport_id, - old_info->vlan_tag, - true); - if (ret) - return ret; + ret = hclge_set_vlan_filter_hw(hdev, htons(old_info->vlan_proto), + vport->vport_id, old_info->vlan_tag, + true); + if (ret) + return ret; - hclge_add_vport_all_vlan_table(vport); - return 0; - } + return hclge_add_vport_all_vlan_table(vport); } int hclge_update_port_base_vlan_cfg(struct hclge_vport *vport, u16 state, -- GitLab