Skip to content

dmaengine: dma-jz4780: free the correct descriptor on prep error - #19

Open
wormuz wants to merge 1 commit into
OpenDingux:jz-6.13from
wormuz:fix/jz4780-dma-prep-wrong-free
Open

dmaengine: dma-jz4780: free the correct descriptor on prep error#19
wormuz wants to merge 1 commit into
OpenDingux:jz-6.13from
wormuz:fix/jz4780-dma-prep-wrong-free

Conversation

@wormuz

@wormuz wormuz commented Aug 15, 2026

Copy link
Copy Markdown

The error paths of jz4780_dma_prep_slave_sg() and jz4780_dma_prep_dma_cyclic() free jzchan->desc (the descriptor of the transfer currently running on the channel) instead of the descriptor that was just allocated and failed to populate.

If a transfer is in flight when a prep call fails, the running descriptor is returned to the pool while the hardware is still using it, and the newly allocated descriptor is leaked.

Found on an RG350P handheld (JZ4770).

The error paths of jz4780_dma_prep_slave_sg() and
jz4780_dma_prep_dma_cyclic() free jzchan->desc, which is the
descriptor of the transfer currently running on the channel, not
the descriptor that was just allocated and failed to populate.

If a transfer is in flight when a prep call fails (for example an
unaligned scatterlist entry), the running descriptor is returned to
the pool while the hardware is still using it: the DMA controller
keeps reading freed pool memory, and the next allocation hands the
same memory to another transfer. The newly allocated descriptor is
leaked at the same time.

Free the local desc that this function allocated.

Signed-off-by: wormuz <3341798+wormuz@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant