alistair23-linux/net
Gustavo A. R. Silva 391d132cbe nl80211: 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 size_of_regd 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: Johannes Berg <johannes.berg@intel.com>
2019-04-26 13:02:11 +02:00
..
6lowpan
9p 9p/net: fix memory leak in p9_client_create 2019-03-13 11:50:04 +01:00
802
8021q vlan: conditional inclusion of FCoE hooks to match netdevice.h and bnx2x 2019-04-04 17:18:34 -07:00
appletalk appletalk: Fix potential NULL pointer dereference in unregister_snap_client 2019-03-15 11:25:48 -07:00
atm
ax25
batman-adv Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net 2019-04-05 14:14:19 -07:00
bluetooth
bpf
bpfilter
bridge rhashtable: use bit_spin_locks to protect hash bucket. 2019-04-07 19:12:12 -07:00
caif
can
ceph libceph: fix breakage caused by multipage bvecs 2019-03-25 22:28:07 +01:00
core Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net 2019-04-05 14:14:19 -07:00
dcb
dccp dccp: Fix memleak in __feat_register_sp 2019-04-01 18:15:10 -07:00
decnet net: use rcu_dereference_protected to fetch sk_dst_cache in sk_destruct 2019-04-01 18:10:51 -07:00
dns_resolver
dsa Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net 2019-04-05 14:14:19 -07:00
ethernet
hsr net: hsr: Fix node prune function for forget time expiry 2019-04-06 18:32:21 -07:00
ieee802154 genetlink: make policy common to family 2019-03-22 10:38:23 -04:00
ife
ipv4 rhashtable: use bit_spin_locks to protect hash bucket. 2019-04-07 19:12:12 -07:00
ipv6 rhashtable: use bit_spin_locks to protect hash bucket. 2019-04-07 19:12:12 -07:00
iucv
kcm kcm: switch order of device registration to fix a crash 2019-04-01 14:59:20 -07:00
key
l2tp genetlink: make policy common to family 2019-03-22 10:38:23 -04:00
l3mdev
lapb
llc
mac80211 mac80211: debugfs option to force TX status frames 2019-04-26 13:02:11 +02:00
mac802154
mpls ipv6: Move ipv6 stubs to a separate header file 2019-03-29 10:53:45 -07:00
ncsi genetlink: make policy common to family 2019-03-22 10:38:23 -04:00
netfilter rhashtable: use bit_spin_locks to protect hash bucket. 2019-04-07 19:12:12 -07:00
netlabel genetlink: make policy common to family 2019-03-22 10:38:23 -04:00
netlink Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net 2019-03-27 17:37:58 -07:00
netrom
nfc Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net 2019-03-27 17:37:58 -07:00
nsh
openvswitch Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net 2019-04-05 14:14:19 -07:00
packet Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net 2019-03-27 17:37:58 -07:00
phonet
psample
qrtr
rds net: rds: force to destroy connection if t_sock is NULL in rds_tcp_kill_sock(). 2019-03-28 17:17:18 -07:00
rfkill
rose net: rose: fix a possible stack overflow 2019-03-18 16:53:22 -07:00
rxrpc rxrpc: Mark expected switch fall-through 2019-04-03 21:37:58 -07:00
sched net: sched: flower: insert filter to ht before offloading it to hw 2019-04-07 19:33:07 -07:00
sctp sctp: initialize _pad of sockaddr_in before copying to user memory 2019-04-01 18:08:19 -07:00
smc genetlink: make policy common to family 2019-03-22 10:38:23 -04:00
strparser net: strparser: fix a missing check for create_singlethread_workqueue 2019-03-15 12:51:56 -07:00
sunrpc SUNRPC: fix uninitialized variable warning 2019-03-26 13:04:32 -07:00
switchdev
tipc Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net 2019-04-05 14:14:19 -07:00
tls Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net 2019-04-05 14:14:19 -07:00
unix
vmw_vsock
wimax genetlink: make policy common to family 2019-03-22 10:38:23 -04:00
wireless nl80211: Use struct_size() in kzalloc() 2019-04-26 13:02:11 +02:00
x25 net/x25: reset state in x25_connect() 2019-03-11 15:40:14 -07:00
xdp xsk: fix umem memory leak on cleanup 2019-03-16 01:27:51 +01:00
xfrm net: dev: rename queue selection helpers. 2019-03-20 11:18:54 -07:00
compat.c
Kconfig net: devlink: select NET_DEVLINK from drivers 2019-03-24 14:55:31 -04:00
Makefile
socket.c net: add documentation to socket.c 2019-03-15 15:29:47 -07:00
sysctl_net.c