]> git.baikalelectronics.ru Git - kernel.git/commitdiff
net: dsa: rtl8366: Check validity of passed VLANs
authorLinus Walleij <linus.walleij@linaro.org>
Tue, 1 Sep 2020 22:09:34 +0000 (00:09 +0200)
committerDavid S. Miller <davem@davemloft.net>
Wed, 2 Sep 2020 21:13:35 +0000 (14:13 -0700)
The rtl8366_set_vlan() and rtl8366_set_pvid() get invalid
VLANs tossed at it, especially VLAN0, something the hardware
and driver cannot handle. Check validity and bail out like
we do in the other callbacks.

Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/dsa/rtl8366.c

index 8f40fbf70a82b83d33931e1ccc7fc3eadbf6e942..7c34c991c8347b51b188b5c868d4b02a603c54a9 100644 (file)
@@ -43,6 +43,9 @@ int rtl8366_set_vlan(struct realtek_smi *smi, int vid, u32 member,
        int ret;
        int i;
 
+       if (!smi->ops->is_vlan_valid(smi, vid))
+               return -EINVAL;
+
        dev_dbg(smi->dev,
                "setting VLAN%d 4k members: 0x%02x, untagged: 0x%02x\n",
                vid, member, untag);
@@ -118,6 +121,9 @@ int rtl8366_set_pvid(struct realtek_smi *smi, unsigned int port,
        int ret;
        int i;
 
+       if (!smi->ops->is_vlan_valid(smi, vid))
+               return -EINVAL;
+
        /* Try to find an existing MC entry for this VID */
        for (i = 0; i < smi->num_vlan_mc; i++) {
                ret = smi->ops->get_vlan_mc(smi, i, &vlanmc);