diff options
author | Gustavo A. R. Silva <gustavo@embeddedor.com> | 2019-08-30 11:14:23 -0500 |
---|---|---|
committer | Vinod Koul <vkoul@kernel.org> | 2019-09-04 10:25:08 +0530 |
commit | 402096cb5b7d9ae9c69b851f5ec6289d249a9ed5 (patch) | |
tree | c4c60479dcf136185036408d5d011f220e1f7190 /net/ieee802154/Makefile | |
parent | 37256335bd065e200c7e42cfd27b26b688606466 (diff) | |
download | linux-402096cb5b7d9ae9c69b851f5ec6289d249a9ed5.tar.bz2 |
dmaengine: stm32-dma: Use struct_size() helper
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 stm32_dma_desc {
...
struct stm32_dma_sg_req sg_req[];
};
Make use of the struct_size() helper instead of an open-coded version
in order to avoid any potential type mistakes.
So, replace the following function:
static struct stm32_dma_desc *stm32_dma_alloc_desc(u32 num_sgs)
{
return kzalloc(sizeof(struct stm32_dma_desc) +
sizeof(struct stm32_dma_sg_req) * num_sgs, GFP_NOWAIT);
}
with:
kzalloc(struct_size(desc, sg_req, num_sgs), GFP_NOWAIT)
This code was detected with the help of Coccinelle.
Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
Link: https://lore.kernel.org/r/20190830161423.GA3483@embeddedor
Signed-off-by: Vinod Koul <vkoul@kernel.org>
Diffstat (limited to 'net/ieee802154/Makefile')
0 files changed, 0 insertions, 0 deletions