From d0186842ec5f456af531c66ee1ca64a8682695e6 Mon Sep 17 00:00:00 2001 From: Florian Fainelli Date: Thu, 24 Sep 2020 17:27:44 -0700 Subject: 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 Signed-off-by: David S. Miller --- net/8021q/vlan.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'net/8021q/vlan.c') 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) -- cgit