linux-sg2042/net/dsa
Gustavo A. R. Silva 33b363e004 net: dsa: use struct_size() in devm_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 = alloc(size, GFP_KERNEL)

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

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

Notice that, in this case, variable 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: Vivien Didelot <vivien.didelot@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2019-02-08 22:57:27 -08:00
..
Kconfig net: dsa: ksz: Rename NET_DSA_TAG_KSZ to _KSZ9477 2018-12-16 14:23:33 -08:00
Makefile net: dsa: Add Lantiq / Intel GSWIP tag support 2018-09-13 08:14:33 -07:00
dsa.c net: dsa: ksz: Rename NET_DSA_TAG_KSZ to _KSZ9477 2018-12-16 14:23:33 -08:00
dsa2.c net: dsa: use struct_size() in devm_kzalloc() 2019-02-08 22:57:27 -08:00
dsa_priv.h net: Add extack argument to ndo_fdb_add() 2019-01-17 15:18:47 -08:00
legacy.c net: dsa: legacy: simplify getting .driver_data 2018-10-22 19:49:04 -07:00
master.c Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net 2019-02-08 15:00:17 -08:00
port.c rocker, dsa, ethsw: Don't filter VLAN events on bridge itself 2018-11-23 18:02:24 -08:00
slave.c Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net 2019-02-08 15:00:17 -08:00
switch.c net: dsa: Remove VLA usage 2018-07-18 15:08:31 -07:00
tag_brcm.c net: dsa: Add overhead to tag protocol ops. 2018-12-06 12:18:16 -08:00
tag_dsa.c net: dsa: Add overhead to tag protocol ops. 2018-12-06 12:18:16 -08:00
tag_edsa.c net: dsa: Add overhead to tag protocol ops. 2018-12-06 12:18:16 -08:00
tag_gswip.c net: dsa: Add overhead to tag protocol ops. 2018-12-06 12:18:16 -08:00
tag_ksz.c net: dsa: ksz: Add STP multicast handling 2018-12-16 14:23:33 -08:00
tag_lan9303.c net: dsa: Add overhead to tag protocol ops. 2018-12-06 12:18:16 -08:00
tag_mtk.c net: dsa: Add overhead to tag protocol ops. 2018-12-06 12:18:16 -08:00
tag_qca.c net: dsa: Add overhead to tag protocol ops. 2018-12-06 12:18:16 -08:00
tag_trailer.c net: dsa: Add overhead to tag protocol ops. 2018-12-06 12:18:16 -08:00