aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/dma/mcf-edma.c
diff options
context:
space:
mode:
authorGustavo A. R. Silva <gustavo@embeddedor.com>2019-08-30 11:14:23 -0500
committerVinod Koul <vkoul@kernel.org>2019-09-04 10:25:08 +0530
commit402096cb5b7d9ae9c69b851f5ec6289d249a9ed5 (patch)
treec4c60479dcf136185036408d5d011f220e1f7190 /drivers/dma/mcf-edma.c
parentdt-bindings: dmaengine: dma-common: Fix the dma-channel-mask property (diff)
downloadlinux-dev-402096cb5b7d9ae9c69b851f5ec6289d249a9ed5.tar.xz
linux-dev-402096cb5b7d9ae9c69b851f5ec6289d249a9ed5.zip
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 'drivers/dma/mcf-edma.c')
0 files changed, 0 insertions, 0 deletions