linux_dsm_epyc7002/drivers/net/ethernet/mellanox
Gustavo A. R. Silva faa311e950 mlxsw: spectrum_nve: 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[];
};

instance = kzalloc(sizeof(struct foo) + count * sizeof(struct boo), 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);

This issue 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-01-16 09:12:23 -08:00
..
mlx4 Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net 2019-01-16 05:13:36 +12:00
mlx5/core cross-tree: phase out dma_zalloc_coherent() 2019-01-08 07:58:37 -05:00
mlxfw
mlxsw mlxsw: spectrum_nve: Use struct_size() in kzalloc() 2019-01-16 09:12:23 -08:00
Kconfig
Makefile