dmaengine: apple-admac: Fix 'current_tx' not getting freed

[ Upstream commit d9503be5a1 ]

In terminate_all we should queue up all submitted descriptors to be
freed. We do that for the content of the 'issued' and 'submitted' lists,
but the 'current_tx' descriptor falls through the cracks as it's
removed from the 'issued' list once it gets assigned to be the current
descriptor. Explicitly queue up freeing of the 'current_tx' descriptor
to address a memory leak that is otherwise present.

Fixes: b127315d9a ("dmaengine: apple-admac: Add Apple ADMAC driver")
Signed-off-by: Martin Povišer <povik+lin@cutebit.org>
Link: https://lore.kernel.org/r/20230224152222.26732-2-povik+lin@cutebit.org
Signed-off-by: Vinod Koul <vkoul@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
Martin Povišer 2023-02-24 16:22:21 +01:00 committed by Greg Kroah-Hartman
parent fdbd039235
commit b7abd53588
1 changed files with 4 additions and 1 deletions

View File

@ -512,7 +512,10 @@ static int admac_terminate_all(struct dma_chan *chan)
admac_stop_chan(adchan);
admac_reset_rings(adchan);
adchan->current_tx = NULL;
if (adchan->current_tx) {
list_add_tail(&adchan->current_tx->node, &adchan->to_free);
adchan->current_tx = NULL;
}
/*
* Descriptors can only be freed after the tasklet
* has been killed (in admac_synchronize).