]> git.baikalelectronics.ru Git - kernel.git/commitdiff
net: hns3: check vlan id before using it
authorliaoguojia <liaoguojia@huawei.com>
Wed, 15 Sep 2021 13:52:10 +0000 (21:52 +0800)
committerDavid S. Miller <davem@davemloft.net>
Mon, 20 Sep 2021 12:28:39 +0000 (13:28 +0100)
The input parameters may not be reliable, so check the vlan id before
using it, otherwise may set wrong vlan id into hardware.

Fixes: 87d9446f883d ("net: hns3: Fix for packet loss due wrong filter config in VLAN tbls")
Signed-off-by: liaoguojia <liaoguojia@huawei.com>
Signed-off-by: Guangbin Huang <huangguangbin2@huawei.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c

index afc88a41a89c0d83eef754e12102444223202ff2..14e9daf09f8c3dd060b7154e81708682a15f4e47 100644 (file)
@@ -9817,6 +9817,9 @@ static int hclge_set_vlan_filter_hw(struct hclge_dev *hdev, __be16 proto,
        if (is_kill && !vlan_id)
                return 0;
 
+       if (vlan_id >= VLAN_N_VID)
+               return -EINVAL;
+
        ret = hclge_set_vf_vlan_common(hdev, vport_id, is_kill, vlan_id);
        if (ret) {
                dev_err(&hdev->pdev->dev,