Commit c33ee130 authored by Dmitry Osipenko's avatar Dmitry Osipenko Committed by Vinod Koul
Browse files

dmaengine: tegra-apb: Prevent race conditions of tasklet vs free list



The interrupt handler puts a half-completed DMA descriptor on a free list
and then schedules tasklet to process bottom half of the descriptor that
executes client's callback, this creates possibility to pick up the busy
descriptor from the free list. Thus, let's disallow descriptor's re-use
until it is fully processed.

Signed-off-by: default avatarDmitry Osipenko <digetx@gmail.com>
Acked-by: default avatarJon Hunter <jonathanh@nvidia.com>
Cc: <stable@vger.kernel.org>
Link: https://lore.kernel.org/r/20200209163356.6439-3-digetx@gmail.com


Signed-off-by: default avatarVinod Koul <vkoul@kernel.org>
parent 94788af4
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -281,7 +281,7 @@ static struct tegra_dma_desc *tegra_dma_desc_get(

	/* Do not allocate if desc are waiting for ack */
	list_for_each_entry(dma_desc, &tdc->free_dma_desc, node) {
		if (async_tx_test_ack(&dma_desc->txd)) {
		if (async_tx_test_ack(&dma_desc->txd) && !dma_desc->cb_count) {
			list_del(&dma_desc->node);
			spin_unlock_irqrestore(&tdc->lock, flags);
			dma_desc->txd.flags = 0;