Skip to contentSkip to conversation

net: vlan: Avoid using BUG() in vlan_proto_idx()

bug report Dan Carpenter 2 participants 2 messages Sep 29, 2020 Kernel janitors

lore
Share & tools
lore
#0 lore raw

Hello Florian Fainelli,

The patch d0186842ec5f: "net: vlan: Avoid using BUG() in vlan_proto_idx()" from Sep 24, 2020, leads to the following static checker warning:

	net/8021q/vlan.c:60 vlan_group_prealloc_vid()
	warn: unsigned 'pidx' is never less than zero.

net/8021q/vlan.c

    50  static int vlan_group_prealloc_vid(struct vlan_group *vg,
    51                                     __be16 vlan_proto, u16 vlan_id)
    52  {
    53          struct net_device **array;
    54          unsigned int pidx, vidx;
                ^^^^^^^^^^^^^^^^^^^^^^^^

    55          unsigned int size;
    56  
    57          ASSERT_RTNL();
    58  
    59          pidx  = vlan_proto_idx(vlan_proto);
    60          if (pidx < 0)
                    ^^^^^^^^

This is unsigned.

    61                  return -EINVAL;
    62  
    63          vidx  = vlan_id / VLAN_GROUP_ARRAY_PART_LEN;
    64          array = vg->vlan_devices_arrays[pidx][vidx];
    65          if (array != NULL)
    66                  return 0;

regards,
dan carpenter

#1 lore raw
Quoted 8 lines · Dan Carpenter

Hello Florian Fainelli,

The patch d0186842ec5f: "net: vlan: Avoid using BUG() in vlan_proto_idx()" from Sep 24, 2020, leads to the following static checker warning:

	net/8021q/vlan.c:60 vlan_group_prealloc_vid()
	warn: unsigned 'pidx' is never less than zero.

Fixed with:

https://git.kernel.org/pub/scm/linux/kernel/git/netdev/net-next.git/commit/?id75c285ea65540cccae64c87dfc7a00c7ede03a

Thanks

Signature · 1 line
Florian