]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
net: hns3: MAC table entry count function increases operation 0 value protection...
authorliuzhongzhu <liuzhongzhu@huawei.com>
Sat, 2 Feb 2019 14:39:37 +0000 (22:39 +0800)
committerDavid S. Miller <davem@davemloft.net>
Sat, 2 Feb 2019 16:24:09 +0000 (08:24 -0800)
When updating the available MAC VLAN table counts,
MAC VLAN table entry count function adds
operation 0 value protection measures.

Signed-off-by: liuzhongzhu <liuzhongzhu@huawei.com>
Signed-off-by: Peng Li <lipeng321@huawei.com>
Signed-off-by: Huazhong Tan <tanhuazhong@huawei.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c

index f55835dee5c77ad7b9291a9992f19312c8f5df02..0a64c7f2dc6cd26da6c238721379374f63d24bd2 100644 (file)
@@ -5830,9 +5830,12 @@ static void hclge_update_umv_space(struct hclge_vport *vport, bool is_free)
        if (is_free) {
                if (vport->used_umv_num > hdev->priv_umv_size)
                        hdev->share_umv_size++;
-               vport->used_umv_num--;
+
+               if (vport->used_umv_num > 0)
+                       vport->used_umv_num--;
        } else {
-               if (vport->used_umv_num >= hdev->priv_umv_size)
+               if (vport->used_umv_num >= hdev->priv_umv_size &&
+                   hdev->share_umv_size > 0)
                        hdev->share_umv_size--;
                vport->used_umv_num++;
        }