aboutsummaryrefslogtreecommitdiff
path: root/sound
diff options
context:
space:
mode:
authorGustavo A. R. Silva2019-06-10 10:04:12 -0500
committerJens Axboe2019-06-15 01:47:58 -0600
commitf1f8f292cd12292289cae87aac3a5c035186ec54 (patch)
tree849c847a9195ed97b0cb733da4e921aed6870ff5 /sound
parent78b90a2ce8424eb4be4a6a1623dc7c07af8303aa (diff)
block: bio: 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 bio_map_data { ... struct iovec iov[]; }; instance = kmalloc(sizeof(sizeof(struct bio_map_data) + sizeof(struct iovec) * 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, iov, count), GFP_KERNEL); This code was detected with the help of Coccinelle. Reviewed-by: Kees Cook <keescook@chromium.org> Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com> Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'sound')
0 files changed, 0 insertions, 0 deletions