[PATCH v2] spi: atmel: fix DMA channel and bounce buffer leaks
Mark Brown
broonie at kernel.org
Tue May 19 06:48:35 PDT 2026
On Sun, May 17, 2026 at 06:39:54PM +0800, Felix Gu wrote:
> Changes in v2:
> - Switch to devm-managed variants to fix Claudiu Beznea's comment.
The switch to devm is possibly a bit enthusiastic.
> - host->dma_tx = dma_request_chan(dev, "tx");
> + host->dma_tx = devm_dma_request_chan(dev, "tx");
> if (IS_ERR(host->dma_tx)) {
> - host->dma_rx = dma_request_chan(dev, "rx");
> + host->dma_rx = devm_dma_request_chan(dev, "rx");
> if (IS_ERR(host->dma_rx)) {
> err = PTR_ERR(host->dma_rx);
> /*
> @@ -580,12 +581,27 @@ static int atmel_spi_configure_dma(struct spi_controller *host,
> * requested tx channel.
> */
> dev_dbg(dev, "No RX DMA channel, DMA is disabled\n");
> - goto error;
> + host->dma_rx = NULL;
> + return err;
> }
If the rx allocation fails then instead of jumping to cleanup we'll
return, and since the driver supports PIO operation it'll still be able
to probe...
> -error:
> - if (!IS_ERR(host->dma_rx))
> - dma_release_channel(host->dma_rx);
> - if (!IS_ERR(host->dma_tx))
> - dma_release_channel(host->dma_tx);
...with the tx DMA channel still allocated. This is very much an edge
case though, how much it matters is very questionalble.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20260519/6f9a84ea/attachment.sig>
More information about the linux-arm-kernel
mailing list