linux/drivers/net
Gustavo A. R. Silva 370600afdd bnx2x: 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 fsz 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>
Signed-off-by: David S. Miller <davem@davemloft.net>
2019-02-08 22:57:28 -08:00
..
appletalk net: appletalk: cops: mark expected switch fall-through 2019-02-08 11:53:42 -08:00
arcnet
bonding bonding: count master 3ad stats separately 2019-01-24 22:18:48 -08:00
caif net: caif: call dev_consume_skb_any when skb xmit done 2019-01-29 10:09:28 -08:00
can can: flexcan: fix NULL pointer exception during bringup 2019-01-22 11:35:33 +01:00
dsa net: dsa: bcm_sf2: Allow looping back CFP rules 2019-02-08 22:11:07 -08:00
ethernet bnx2x: Use struct_size() in kzalloc() 2019-02-08 22:57:28 -08:00
fddi Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net 2019-02-08 15:00:17 -08:00
fjes fjes: convert to DEFINE_SHOW_ATTRIBUTE 2018-12-10 12:05:20 -08:00
hamradio net/hamradio/6pack: use mod_timer() to rearm timers 2019-01-02 10:27:01 -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-08 15:00:17 -08:00
netdevsim netdevsim: Implement ndo_get_port_parent_id() 2019-02-06 14:17:03 -08:00
phy net: phy: consider latched link-down status in polling mode 2019-02-08 22:09:11 -08:00
plip
ppp net: Fix usage of pskb_trim_rcsum 2019-01-18 14:05:14 -08:00
slip
team net: dev: Add extack argument to dev_set_mac_address() 2018-12-13 18:41:38 -08:00
usb net: usb: cdc-phonet: use struct_size() in alloc_netdev() 2019-02-08 22:57:27 -08:00
vmxnet3 cross-tree: phase out dma_zalloc_coherent() 2019-01-08 07:58:37 -05:00
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-08 15:00:17 -08:00
xen-netback xen-netback: mark expected switch fall-through 2019-02-08 12:21:21 -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 ipvlan: decouple l3s mode dependencies from other modes 2019-02-08 11:16:48 -08:00
LICENSE.SRC
loopback.c
macsec.c
macvlan.c macvlan: use netif_is_macvlan_port() 2019-01-31 09:26:31 -08:00
macvtap.c
Makefile
mdio.c
mii.c
net_failover.c
netconsole.c
nlmon.c
ntb_netdev.c
rionet.c
sb1000.c sb1000: fix a couple of indentation issues and remove assignment in if statements 2019-01-17 21:51:36 -08:00
Space.c
sungem_phy.c
tap.c tap: call skb_probe_transport_header after setting skb->dev 2019-01-01 12:01:02 -08:00
thunderbolt.c
tun.c tun: move the call to tun_set_real_num_queues 2019-01-30 21:40:25 -08:00
veth.c veth: Mark expected switch fall-throughs 2019-02-08 11:51:52 -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
vsockmon.c
vxlan.c net: vxlan: Free a leaked vetoed multicast rdst 2019-02-07 11:17:08 -08:00
xen-netfront.c Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net 2018-12-20 11:53:36 -08:00