]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
spi: atmel: fix DMA channel and bounce buffer leaks
authorFelix Gu <ustc.gu@gmail.com>
Fri, 22 May 2026 12:40:48 +0000 (20:40 +0800)
committerMark Brown <broonie@kernel.org>
Mon, 1 Jun 2026 14:03:02 +0000 (15:03 +0100)
commitbd7e9843ec95bffe2643c901dd625f0bab32e639
tree3efd432a2465cfba85eff3df55251799e9e03516
parent82056957e5c42c4060a1d8b1576aad2dfe54e568
spi: atmel: fix DMA channel and bounce buffer leaks

The original code set use_dma to false when dma_alloc_coherent() for
bounce buffers failed, but DMA channels acquired earlier via
atmel_spi_configure_dma() were never freed.

When devm_request_irq() or clk_prepare_enable() failed later in probe,
the driver also did not release DMA channels or bounce buffers already
allocated.

The out_free_dma error path released DMA channels but did not free the
bounce buffers.

Fix by moving bounce buffer allocation into atmel_spi_configure_dma()
and registering the devres cleanup for DMA channels and bounce buffers.

Fixes: a9889ed62d06 ("spi: atmel: Implements transfers with bounce buffer")
Signed-off-by: Felix Gu <ustc.gu@gmail.com>
Link: https://patch.msgid.link/20260522-atmel-v3-1-23f8c6e6aa43@gmail.com
Signed-off-by: Mark Brown <broonie@kernel.org>
drivers/spi/spi-atmel.c