linux_old1/net/sunrpc/xprtrdma
Gustavo A. R. Silva 66d4218f99 xprtrdma: 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 code was detected with the help of Coccinelle.

Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
Reviewed-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>
2019-05-28 09:28:49 -04:00
..
Makefile xprtrdma: Remove support for FMR memory registration 2019-01-02 12:05:17 -05:00
backchannel.c xprtrdma: Aggregate the inline settings in struct rpcrdma_ep 2019-04-25 15:39:16 -04:00
frwr_ops.c xprtrdma: Remove pr_err() call sites from completion handlers 2019-04-25 15:40:09 -04:00
module.c NFS client updates for Linux 4.18 2018-06-12 10:09:03 -07:00
rpc_rdma.c xprtrdma: Aggregate the inline settings in struct rpcrdma_ep 2019-04-25 15:39:16 -04:00
svc_rdma.c sunrpc: remove svc_rdma_bc_class 2018-12-27 21:01:41 -05:00
svc_rdma_backchannel.c SUNRPC: Refactor xprt_request_wait_receive() 2019-04-25 14:18:12 -04:00
svc_rdma_recvfrom.c svcrdma: Remove syslog warnings in work completion handlers 2019-02-06 15:37:15 -05:00
svc_rdma_rw.c svcrdma: Remove syslog warnings in work completion handlers 2019-02-06 15:37:15 -05:00
svc_rdma_sendto.c svcrdma: Remove syslog warnings in work completion handlers 2019-02-06 15:37:15 -05:00
svc_rdma_transport.c svcrdma: Remove syslog warnings in work completion handlers 2019-02-06 15:37:15 -05:00
transport.c xprtrdma: Eliminate struct rpcrdma_create_data_internal 2019-04-25 15:39:40 -04:00
verbs.c xprtrdma: Use struct_size() in kzalloc() 2019-05-28 09:28:49 -04:00
xprt_rdma.h xprtrdma: Remove stale comment 2019-04-25 15:42:04 -04:00