1
0
Fork 0
alistair23-linux/drivers/net
Gustavo A. R. Silva 0cf83903aa brcmfmac: 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 reqsz 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: Kalle Valo <kvalo@codeaurora.org>
2019-04-13 13:58:36 +03:00
..
appletalk net: appletalk: cops: mark expected switch fall-through 2019-02-08 11:53:42 -08:00
arcnet
bonding net: remove 'fallback' argument from dev->ndo_select_queue() 2019-03-20 11:18:55 -07:00
caif net: caif: pass struct device to DMA API functions 2019-02-12 12:09:23 -05:00
can peak_usb: fix clang build warning 2019-03-07 09:39:46 -08:00
dsa Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net 2019-03-27 17:37:58 -07:00
ethernet cxgb4/cxgb4vf: Display advertised FEC in ethtool 2019-03-29 13:47:38 -07: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 net: remove 'fallback' argument from dev->ndo_select_queue() 2019-03-20 11:18:55 -07:00
ieee802154 Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net 2019-03-27 17:37:58 -07: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 Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net 2019-03-27 17:37:58 -07:00
plip
ppp pptp: dst_release sk_dst_cache in pptp_sock_destruct 2019-03-13 14:22:49 -07:00
slip
team team: use netif_is_team_port() 2019-03-29 13:48:11 -07:00
usb ipv6: Move ipv6 stubs to a separate header file 2019-03-29 10:53:45 -07:00
vmxnet3
wan net: wan: z85230: replace dev_kfree_skb_irq by dev_consume_skb_irq for drop profiles 2019-02-25 14:36:15 -08:00
wimax wimax/i2400m: use struct_size() helper 2019-02-08 22:57:28 -08:00
wireless brcmfmac: Use struct_size() in kzalloc() 2019-04-13 13:58:36 +03:00
xen-netback net: remove 'fallback' argument from dev->ndo_select_queue() 2019-03-20 11:18:55 -07:00
Kconfig net: devlink: select NET_DEVLINK from drivers 2019-03-24 14:55:31 -04:00
LICENSE.SRC
Makefile
Space.c
dummy.c
eql.c
geneve.c ipv6: Move ipv6 stubs to a separate header file 2019-03-29 10:53:45 -07:00
gtp.c genetlink: make policy common to family 2019-03-22 10:38:23 -04:00
ifb.c
loopback.c
macsec.c genetlink: make policy common to family 2019-03-22 10:38:23 -04:00
macvlan.c macvlan: pass get_ts_info and SIOC[SG]HWTSTAMP ioctl to real device 2019-03-20 11:04:41 -07:00
macvtap.c
mdio.c
mii.c
net_failover.c net: remove 'fallback' argument from dev->ndo_select_queue() 2019-03-20 11:18:55 -07:00
netconsole.c
nlmon.c
ntb_netdev.c
rionet.c
sb1000.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: convert rps_needed and rfs_needed to new static branch api 2019-03-23 21:57:38 -04:00
veth.c veth: Fix -Wformat-truncation 2019-02-23 13:44:58 -08:00
virtio_net.c virtio_net: remove hcpu from virtnet_clean_affinity 2019-03-18 22:26:23 -07:00
vrf.c net: vrf: remove MTU limits for vrf device 2019-02-21 13:10:08 -08:00
vsockmon.c
vxlan.c ipv6: Move ipv6 stubs to a separate header file 2019-03-29 10:53:45 -07:00
xen-netfront.c net: remove 'fallback' argument from dev->ndo_select_queue() 2019-03-20 11:18:55 -07:00