]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
dmaengine: dma-jz4780: Fix race in jz4780_dma_tx_status
authorPaul Cercueil <paul@crapouillou.net>
Sun, 4 Oct 2020 14:03:07 +0000 (16:03 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 5 Nov 2020 10:08:50 +0000 (11:08 +0100)
commitfd9079bdc25c2d004da5294f91ddaf844818618a
treef141dc254085b572ceedd287da8b1c3eacc7e5d3
parent9bbfd6578e596d3bf480e74d142e49c88102014d
dmaengine: dma-jz4780: Fix race in jz4780_dma_tx_status

commit baf6fd97b16ea8f981b8a8b04039596f32fc2972 upstream.

The jz4780_dma_tx_status() function would check if a channel's cookie
state was set to 'completed', and if not, it would enter the critical
section. However, in that time frame, the jz4780_dma_chan_irq() function
was able to set the cookie to 'completed', and clear the jzchan->vchan
pointer, which was deferenced in the critical section of the first
function.

Fix this race by checking the channel's cookie state after entering the
critical function and not before.

Fixes: d894fc6046fe ("dmaengine: jz4780: add driver for the Ingenic JZ4780 DMA controller")
Cc: stable@vger.kernel.org # v4.0
Signed-off-by: Paul Cercueil <paul@crapouillou.net>
Reported-by: Artur Rojek <contact@artur-rojek.eu>
Tested-by: Artur Rojek <contact@artur-rojek.eu>
Link: https://lore.kernel.org/r/20201004140307.885556-1-paul@crapouillou.net
Signed-off-by: Vinod Koul <vkoul@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/dma/dma-jz4780.c