Skip to content

Commit

Permalink
net: dsa: rtl8366: Check validity of passed VLANs
Browse files Browse the repository at this point in the history
[ Upstream commit 6641a2c ]

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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
linusw authored and gregkh committed Oct 29, 2020
1 parent 701c56f commit 6aa894f
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions drivers/net/dsa/rtl8366.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 6aa894f

Please sign in to comment.