summaryrefslogtreecommitdiff
path: root/net/8021q/vlan.c
diff options
context:
space:
mode:
authorFlorian Fainelli <f.fainelli@gmail.com>2020-09-25 03:27:44 +0300
committerDavid S. Miller <davem@davemloft.net>2020-09-26 00:12:18 +0300
commitd0186842ec5f456af531c66ee1ca64a8682695e6 (patch)
tree1128c50e3baff5b3b8016e4d6d8bf8355cb73bf2 /net/8021q/vlan.c
parent7806f6561cd51de382f7628e7f4ecef4568d88da (diff)
downloadlinux-d0186842ec5f456af531c66ee1ca64a8682695e6.tar.xz
net: vlan: Avoid using BUG() in vlan_proto_idx()
While we should always make sure that we specify a valid VLAN protocol to vlan_proto_idx(), killing the machine when an invalid value is specified is too harsh and not helpful for debugging. All callers are capable of dealing with an error returned by vlan_proto_idx() so check the index value and propagate it accordingly. Signed-off-by: Florian Fainelli <f.fainelli@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/8021q/vlan.c')
-rw-r--r--net/8021q/vlan.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/net/8021q/vlan.c b/net/8021q/vlan.c
index d4bcfd8f95bf..6c08de1116c1 100644
--- a/net/8021q/vlan.c
+++ b/net/8021q/vlan.c
@@ -57,6 +57,9 @@ static int vlan_group_prealloc_vid(struct vlan_group *vg,
ASSERT_RTNL();
pidx = vlan_proto_idx(vlan_proto);
+ if (pidx < 0)
+ return -EINVAL;
+
vidx = vlan_id / VLAN_GROUP_ARRAY_PART_LEN;
array = vg->vlan_devices_arrays[pidx][vidx];
if (array != NULL)