Netdev Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Linus Walleij <linus.walleij@linaro.org>
To: Andrew Lunn <andrew@lunn.ch>,
Vivien Didelot <vivien.didelot@gmail.com>,
Florian Fainelli <f.fainelli@gmail.com>,
netdev@vger.kernel.org, "David S . Miller" <davem@davemloft.net>
Cc: Linus Walleij <linus.walleij@linaro.org>
Subject: [net-next PATCH 1/2] net: dsa: rtl8366: Check validity of passed VLANs
Date: Sun, 23 Aug 2020 22:59:43 +0200 [thread overview]
Message-ID: <20200823205944.127796-2-linus.walleij@linaro.org> (raw)
In-Reply-To: <20200823205944.127796-1-linus.walleij@linaro.org>
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.
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---
drivers/net/dsa/rtl8366.c | 6 ++++++
1 file changed, 6 insertions(+)
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);
--
2.26.2
next prev parent reply other threads:[~2020-08-23 21:00 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-08-23 20:59 [net-next PATCH 0/2] RTL8366 stabilization Linus Walleij
2020-08-23 20:59 ` Linus Walleij [this message]
2020-08-23 20:59 ` [net-next PATCH 2/2] net: dsa: rtl8366: Refactor VLAN/PVID init Linus Walleij
2020-08-24 2:06 ` Florian Fainelli
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200823205944.127796-2-linus.walleij@linaro.org \
--to=linus.walleij@linaro.org \
--cc=andrew@lunn.ch \
--cc=davem@davemloft.net \
--cc=f.fainelli@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=vivien.didelot@gmail.com \
--subject='Re: [net-next PATCH 1/2] net: dsa: rtl8366: Check validity of passed VLANs' \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).