Skip to content

Commit b53b831

Browse files
keesvinodkoul
authored andcommitted
dmaengine: stm32-dma3: Set lli_size after allocation
With the new __counted_by annotation, the "lli_size" variable needs to valid for accesses to the "lli" array. This requirement is not met in stm32_dma3_chan_desc_alloc(), since "lli_size" starts at "0", so "lli" index "0" will not be considered valid during the initialization for loop. Fix this by setting lli_size immediately after allocation (similar to how this is handled in stm32_mdma_alloc_desc() for the node/count relationship). Fixes: f561ec8 ("dmaengine: Add STM32 DMA3 support") Signed-off-by: Kees Cook <[email protected]> Reviewed-by: Gustavo A. R. Silva <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Vinod Koul <[email protected]>
1 parent 5e5c793 commit b53b831

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/dma/stm32/stm32-dma3.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -403,14 +403,14 @@ static struct stm32_dma3_swdesc *stm32_dma3_chan_desc_alloc(struct stm32_dma3_ch
403403
swdesc = kzalloc(struct_size(swdesc, lli, count), GFP_NOWAIT);
404404
if (!swdesc)
405405
return NULL;
406+
swdesc->lli_size = count;
406407

407408
for (i = 0; i < count; i++) {
408409
swdesc->lli[i].hwdesc = dma_pool_zalloc(chan->lli_pool, GFP_NOWAIT,
409410
&swdesc->lli[i].hwdesc_addr);
410411
if (!swdesc->lli[i].hwdesc)
411412
goto err_pool_free;
412413
}
413-
swdesc->lli_size = count;
414414
swdesc->ccr = 0;
415415

416416
/* Set LL base address */

0 commit comments

Comments
 (0)