linux_dsm_epyc7002/drivers/infiniband/ulp
Gustavo A. R. Silva 7a7b0fea6f IB/srp: 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;
    void *entry[];
};

instance = kzalloc(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 = kzalloc(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>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
2019-01-08 15:46:59 -07:00
..
ipoib IB/ipoib: drop useless LIST_HEAD 2019-01-02 15:42:43 -07:00
iser 4.21 merge window pull request 2018-12-28 14:57:10 -08:00
isert RDMA/ulp: Use dev_name instead of ibdev->name 2018-09-26 13:51:48 -06:00
opa_vnic RDMA: Mark if destroy address handle is in a sleepable context 2018-12-19 16:28:03 -07:00
srp IB/srp: Use struct_size() in kzalloc() 2019-01-08 15:46:59 -07:00
srpt 4.21 merge window pull request 2018-12-28 14:57:10 -08:00
Makefile