linux/drivers/net
Gustavo A. R. Silva 856e6d9f9d nfp: flower: use struct_size() helper
One of the more common cases of allocation size calculations is finding
the size of a structure that has a zero-sized array at the end, along
with memory for some number of elements for that array. For example:

struct nfp_tun_active_tuns {
	...
        struct route_ip_info {
                __be32 ipv4;
                __be32 egress_port;
                __be32 extra[2];
        } tun_info[];
};

Make use of the struct_size() helper instead of an open-coded version
in order to avoid any potential type mistakes.

So, replace the following form:

sizeof(struct nfp_tun_active_tuns) + sizeof(struct route_ip_info) * count

with:

struct_size(payload, tun_info, count)

This code was detected with the help of Coccinelle.

Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
Acked-by: Jakub Kicinski <jakub.kicinski@netronome.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2019-06-05 16:54:43 -07:00
..
appletalk treewide: Add SPDX license identifier - Makefile/Kconfig 2019-05-21 10:50:46 +02:00
arcnet treewide: Add SPDX license identifier - Makefile/Kconfig 2019-05-21 10:50:46 +02:00
bonding net: bonding: Inherit MPLS features from slave devices 2019-06-04 14:49:38 -07:00
caif treewide: Add SPDX license identifier - Makefile/Kconfig 2019-05-21 10:50:46 +02:00
can treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 13 2019-05-21 11:28:45 +02:00
dsa net: dsa: mv88e6xxx: refactor mv88e6352_g1_reset 2019-06-04 20:07:57 -07:00
ethernet nfp: flower: use struct_size() helper 2019-06-05 16:54:43 -07:00
fddi Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net 2019-05-22 08:28:16 -07:00
fjes
hamradio treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 69 2019-05-24 17:36:47 +02:00
hippi treewide: Add SPDX license identifier - Makefile/Kconfig 2019-05-21 10:50:46 +02:00
hyperv netvsc: unshare skb in VF rx handler 2019-05-30 11:12:21 -07:00
ieee802154 treewide: Add SPDX license identifier - Makefile/Kconfig 2019-05-21 10:50:46 +02:00
ipvlan treewide: Add SPDX license identifier - Makefile/Kconfig 2019-05-21 10:50:46 +02:00
netdevsim netdevsim: implement fake flash updating with notifications 2019-06-04 14:21:40 -07:00
phy net: sfp: remove sfp-bus use of netdevs 2019-05-31 12:37:46 -07:00
plip net: ipv4: provide __rcu annotation for ifa_list 2019-06-02 18:08:36 -07:00
ppp SPDX update for 5.2-rc2, round 1 2019-05-21 12:33:38 -07:00
slip treewide: Add SPDX license identifier - Makefile/Kconfig 2019-05-21 10:50:46 +02:00
team treewide: Add SPDX license identifier - Makefile/Kconfig 2019-05-21 10:50:46 +02:00
usb Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net 2019-05-22 08:28:16 -07:00
vmxnet3 vmxnet3: turn off lro when rxcsum is disabled 2019-06-04 20:05:56 -07:00
wan drivers: use in_dev_for_each_ifa_rtnl/rcu 2019-06-02 18:06:26 -07:00
wimax treewide: Add SPDX license identifier - Makefile/Kconfig 2019-05-21 10:50:46 +02:00
wireless net: ipv4: provide __rcu annotation for ifa_list 2019-06-02 18:08:36 -07:00
xen-netback xen-netback: remove redundant assignment to err 2019-05-31 14:36:48 -07:00
dummy.c treewide: Add SPDX license identifier for more missed files 2019-05-21 10:50:45 +02:00
eql.c
geneve.c
gtp.c
ifb.c
Kconfig treewide: Add SPDX license identifier - Makefile/Kconfig 2019-05-21 10:50:46 +02:00
LICENSE.SRC
loopback.c
macsec.c
macvlan.c macvlan: Replace strncpy() by strscpy() 2019-05-29 00:00:01 -07:00
macvtap.c treewide: Add SPDX license identifier for more missed files 2019-05-21 10:50:45 +02:00
Makefile net: Always descend into dsa/ 2019-05-14 15:20:11 -07:00
mdio.c
mii.c
net_failover.c
netconsole.c
nlmon.c treewide: Add SPDX license identifier for more missed files 2019-05-21 10:50:45 +02:00
ntb_netdev.c
rionet.c
sb1000.c
Space.c
sungem_phy.c treewide: Add SPDX license identifier for more missed files 2019-05-21 10:50:45 +02:00
tap.c treewide: Add SPDX license identifier for more missed files 2019-05-21 10:50:45 +02:00
thunderbolt.c
tun.c tuntap: synchronize through tfiles array instead of tun->numqueues 2019-05-09 09:21:42 -07:00
veth.c treewide: Add SPDX license identifier for more missed files 2019-05-21 10:50:45 +02:00
virtio_net.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 13 2019-05-21 11:28:45 +02:00
vrf.c
vsockmon.c treewide: Add SPDX license identifier for more missed files 2019-05-21 10:50:45 +02:00
vxlan.c
xen-netfront.c