linux_dsm_epyc7002/drivers/net
Gustavo A. R. Silva 78844068a7 mlxsw: spectrum: acl: Use struct_size() in kzalloc()
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 foo {
    int stuff;
    struct boo entry[];
};

size = sizeof(struct foo) + count * sizeof(struct boo);
instance = kzalloc(size, GFP_KERNEL)

Instead of leaving these open-coded and prone to type mistakes, we can
now use the new struct_size() helper:

instance = kzalloc(struct_size(instance, entry, count), GFP_KERNEL)

Notice that, in this case, variable alloc_size is not necessary, hence
it is removed.

This code was detected with the help of Coccinelle.

Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
Reviewed-by: Ido Schimmel <idosch@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2019-02-25 14:18:02 -08:00
..
appletalk net: appletalk: cops: mark expected switch fall-through 2019-02-08 11:53:42 -08:00
arcnet
bonding net: Remove switchdev.h inclusion from team/bond/vlan 2019-02-24 17:40:46 -08:00
caif net: caif: pass struct device to DMA API functions 2019-02-12 12:09:23 -05:00
can
dsa net: dsa: mv88e6xxx: Fix phylink_validate for Topaz family 2019-02-25 09:47:09 -08:00
ethernet mlxsw: spectrum: acl: Use struct_size() in kzalloc() 2019-02-25 14:18:02 -08:00
fddi Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net 2019-02-08 15:00:17 -08:00
fjes
hamradio net: hamradio: remove unused hweight*() defines 2019-02-18 12:10:02 -08:00
hippi
hyperv hv_netvsc: fix typos in code comments 2019-01-23 13:21:34 -05:00
ieee802154 ieee802154: mcr20a: fix indentation, remove tabs 2019-01-31 17:42:05 +01:00
ipvlan Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net 2019-02-24 12:06:19 -08:00
netdevsim bpf: offload: add priv field for drivers 2019-02-12 17:07:09 +01:00
phy net: phy: aquantia: add hwmon support 2019-02-25 14:16:22 -08:00
plip
ppp
slip
team net: Remove switchdev.h inclusion from team/bond/vlan 2019-02-24 17:40:46 -08:00
usb Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net 2019-02-24 12:06:19 -08:00
vmxnet3
wan wan: wanxl: use struct_size() in kzalloc() 2019-02-08 22:57:28 -08:00
wimax wimax/i2400m: use struct_size() helper 2019-02-08 22:57:28 -08:00
wireless Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net 2019-02-24 12:06:19 -08:00
xen-netback net: Don't set transport offset to invalid value 2019-02-22 12:55:31 -08:00
dummy.c
eql.c
geneve.c geneve: should not call rt6_lookup() when ipv6 was disabled 2019-02-07 10:48:42 -08:00
gtp.c
ifb.c
Kconfig Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net 2019-02-15 12:38:38 -08:00
LICENSE.SRC
loopback.c
macsec.c
macvlan.c macvlan: add ndo_change_proto_down support 2019-02-24 13:01:04 -08:00
macvtap.c
Makefile
mdio.c
mii.c
net_failover.c
netconsole.c
nlmon.c
ntb_netdev.c
rionet.c
sb1000.c
Space.c
sungem_phy.c
tap.c net: Don't set transport offset to invalid value 2019-02-22 12:55:31 -08:00
thunderbolt.c
tun.c net: Don't set transport offset to invalid value 2019-02-22 12:55:31 -08:00
veth.c veth: Fix -Wformat-truncation 2019-02-23 13:44:58 -08:00
virtio_net.c Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net 2019-02-08 15:00:17 -08:00
vrf.c net: vrf: remove MTU limits for vrf device 2019-02-21 13:10:08 -08:00
vsockmon.c
vxlan.c vxlan: add ndo_change_proto_down support 2019-02-24 13:01:05 -08:00
xen-netfront.c