]> git.baikalelectronics.ru Git - kernel.git/commit
dmaengine: xilinx_dma: Fix read-after-free bug when terminating transfers
authorAdrian Larumbe <adrian.martinezlarumbe@imgtec.com>
Tue, 6 Jul 2021 23:43:38 +0000 (00:43 +0100)
committerSasha Levin <sashal@kernel.org>
Thu, 26 Aug 2021 12:36:13 +0000 (08:36 -0400)
commitca0b06f4cf64a9cded78f0a73623d05bdc54a5c0
tree9908cafa0d399edb8529879302f23076533e6586
parentbe1e71f547d1063ccd7054fcb48ee76bce23c645
dmaengine: xilinx_dma: Fix read-after-free bug when terminating transfers

[ Upstream commit 7dd2dd4ff9f3abda601f22b9d01441a0869d20d7 ]

When user calls dmaengine_terminate_sync, the driver will clean up any
remaining descriptors for all the pending or active transfers that had
previously been submitted. However, this might happen whilst the tasklet is
invoking the DMA callback for the last finished transfer, so by the time it
returns and takes over the channel's spinlock, the list of completed
descriptors it was traversing is no longer valid. This leads to a
read-after-free situation.

Fix it by signalling whether a user-triggered termination has happened by
means of a boolean variable.

Signed-off-by: Adrian Larumbe <adrian.martinezlarumbe@imgtec.com>
Link: https://lore.kernel.org/r/20210706234338.7696-3-adrian.martinezlarumbe@imgtec.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/dma/xilinx/xilinx_dma.c