diff options
author | Linus Walleij <linus.walleij@linaro.org> | 2020-09-02 01:09:34 +0300 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2020-09-03 00:13:35 +0300 |
commit | 6641a2c42b0a307b7638d10e5d4b90debc61389d (patch) | |
tree | 4c1460cff0a78e2bf71f19df4f54fecb12214cb8 /drivers/net/dsa/rtl8366.c | |
parent | c6f4c2b027c471838f44de03ef8c4100e4986852 (diff) | |
download | linux-6641a2c42b0a307b7638d10e5d4b90debc61389d.tar.xz |
net: dsa: rtl8366: Check validity of passed VLANs
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>
Diffstat (limited to 'drivers/net/dsa/rtl8366.c')
-rw-r--r-- | drivers/net/dsa/rtl8366.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/drivers/net/dsa/rtl8366.c b/drivers/net/dsa/rtl8366.c index 8f40fbf70a82..7c34c991c834 100644 --- a/drivers/net/dsa/rtl8366.c +++ b/drivers/net/dsa/rtl8366.c @@ -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); |