linux/drivers/infiniband
Gustavo A. R. Silva b5c61b968d IB/cm: Use struct_size() in kmalloc()
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;
    void *entry[];
};

instance = kmalloc(sizeof(struct foo) + sizeof(void *) * count, GFP_KERNEL);

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

instance = kmalloc(struct_size(instance, entry, count), GFP_KERNEL);

This code was detected with the help of Coccinelle.

Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
2019-01-07 11:43:03 -07:00
..
core IB/cm: Use struct_size() in kmalloc() 2019-01-07 11:43:03 -07:00
hw 4.21 merge window 2nd pull request 2019-01-05 18:20:51 -08:00
sw IB/rxe: Reuse code which sets port state 2018-12-20 14:20:58 -07:00
ulp IB/ipoib: drop useless LIST_HEAD 2019-01-02 15:42:43 -07:00
Kconfig RDMA: Fix building with CONFIG_MMU=n 2018-10-03 16:01:03 -06:00
Makefile