linux_dsm_epyc7002/drivers/net/ethernet/intel
Gustavo A. R. Silva 439bb9edd4 ixgbe: Use struct_size() helper
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 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 23:03:48 -08:00
..
e1000 cross-tree: phase out dma_zalloc_coherent() 2019-01-08 07:58:37 -05:00
e1000e e1000e: fix cyclic resets at link up with active tx 2019-02-05 17:09:39 -08:00
fm10k fm10k: use struct_size() in kzalloc() 2019-02-08 22:57:28 -08:00
i40e flow_offload: add flow_rule and flow_match structures and use them 2019-02-06 10:38:25 -08:00
iavf flow_offload: add flow_rule and flow_match structures and use them 2019-02-06 10:38:25 -08:00
ice net: Add extack argument to ndo_fdb_add() 2019-01-17 15:18:47 -08:00
igb igb: use struct_size() helper 2019-02-08 23:03:48 -08:00
igbvf ethernet/intel: consolidate NAPI and NAPI exit 2018-11-21 10:35:23 -08:00
igc igc: Use struct_size() helper 2019-02-08 23:03:48 -08:00
ixgb cross-tree: phase out dma_zalloc_coherent() 2019-01-08 07:58:37 -05:00
ixgbe ixgbe: Use struct_size() helper 2019-02-08 23:03:48 -08:00
ixgbevf xfrm: prefer secpath_set over secpath_dup 2018-12-19 11:21:38 -08:00
e100.c e100: Fix passing zero to 'PTR_ERR' warning in e100_load_ucode_wait 2018-12-20 11:54:27 -08:00
Kconfig ixgbe: fix Kconfig when driver is not a module 2019-01-04 14:02:16 -08:00
Makefile igc: Add skeletal frame for Intel(R) 2.5G Ethernet Controller support 2018-10-17 12:14:54 -07:00