summaryrefslogtreecommitdiff
path: root/drivers/net/ifb.c
diff options
context:
space:
mode:
authorGustavo A. R. Silva <gustavo@embeddedor.com>2019-03-29 10:28:41 -0500
committerDavid S. Miller <davem@davemloft.net>2019-04-01 15:01:46 -0700
commitdb4863fdb897f6c55461a0446592c524dae6bfbe (patch)
treed2d5ac1089ee8ebe3d8a46eb1caafe6ce0aea23d /drivers/net/ifb.c
parent76497732932f15e7323dc805e8ea8dc11bb587cf (diff)
downloadlinux-db4863fdb897f6c55461a0446592c524dae6bfbe.tar.gz
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>
Diffstat (limited to 'drivers/net/ifb.c')
0 files changed, 0 insertions, 0 deletions