aboutsummaryrefslogtreecommitdiff
path: root/include/linux
diff options
context:
space:
mode:
authorGustavo A. R. Silva <[email protected]>2019-04-03 15:50:43 -0500
committerGreg Kroah-Hartman <[email protected]>2019-04-16 13:44:30 +0200
commite291fa1237a74dc4692995a4a598d4818a747191 (patch)
treed6a33a3c506686347065ba134e6bc659d2161b23 /include/linux
parent3b706841c29f1cf2f8f3484713288aa2c375677b (diff)
staging: ralink-gdma: 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[]; }; size = sizeof(struct foo) + count * sizeof(struct boo); instance = kzalloc(size, GFP_KERNEL) Instead of leaving these open-coded and prone to type mistakes, we can now use the new struct_size() helper: size = struct_size(instance, entry, count); or instance = kzalloc(struct_size(instance, entry, count), GFP_KERNEL) Based on the above, replace gdma_dma_alloc_desc() with kzalloc() and use the new struct_size() helper. This code was detected with the help of Coccinelle. Signed-off-by: Gustavo A. R. Silva <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
Diffstat (limited to 'include/linux')
0 files changed, 0 insertions, 0 deletions