diff options
author | Gustavo A. R. Silva <gustavo@embeddedor.com> | 2019-01-04 15:25:45 -0600 |
---|---|---|
committer | Vinod Koul <vkoul@kernel.org> | 2019-01-07 18:08:17 +0530 |
commit | de1fa4f61be71725581c8e30f3665aaa20d1610e (patch) | |
tree | c5c06e3583028b71aff5dd036f026bf0ed3e596f /fs | |
parent | 279cc97c01a20477fe33b6705abff8a186761a8a (diff) |
dmaengine: fsl-edma: 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>
Tested-by: Angelo Dureghello <angelo@sysam.it>
Signed-off-by: Vinod Koul <vkoul@kernel.org>
Diffstat (limited to 'fs')
0 files changed, 0 insertions, 0 deletions