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);