linux_dsm_epyc7002/drivers/net/ethernet/chelsio
Gustavo A. R. Silva db4863fdb8 cxgb3/l2t: Use struct_size() in kvzalloc()
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 = kvzalloc(size, GFP_KERNEL);

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

instance = kvzalloc(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-04-01 15:01:46 -07:00
..
cxgb chelsio: clean up indentation issue 2019-02-02 20:14:38 -08:00
cxgb3 cxgb3/l2t: Use struct_size() in kvzalloc() 2019-04-01 15:01:46 -07:00
cxgb4 cxgb4/cxgb4vf: Display advertised FEC in ethtool 2019-03-29 13:47:38 -07:00
cxgb4vf cxgb4/cxgb4vf: Display advertised FEC in ethtool 2019-03-29 13:47:38 -07:00
libcxgb libcxgb: replace vmalloc and memset with vzalloc 2018-07-21 16:32:59 -07:00
Kconfig net: documentation: build a directory structure for drivers 2018-12-05 11:30:06 -08:00
Makefile License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00