The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [PATCH] spi: ep93xx: fix error pointer deref after DMA setup failure
@ 2026-05-12  7:48 Johan Hovold
  2026-05-12 11:31 ` Nikita Shubin
  2026-05-12 12:49 ` Mark Brown
  0 siblings, 2 replies; 3+ messages in thread
From: Johan Hovold @ 2026-05-12  7:48 UTC (permalink / raw)
  To: Mark Brown; +Cc: linux-spi, linux-kernel, Johan Hovold, stable, Nikita Shubin

The driver falls back to PIO mode if DMA setup fails during probe.

Make sure to the clear the DMA channel pointers on setup failure to
avoid dereferencing an error pointer on later probe errors or driver
unbind.

This issue was flagged by Sashiko when reviewing a devres allocation
conversion patch.

Fixes: e79e7c2df627 ("spi: ep93xx: add DT support for Cirrus EP93xx")
Link: https://sashiko.dev/#/patchset/20260429091333.165363-1-johan%40kernel.org?part=10
Cc: stable@vger.kernel.org	# 6.12
Cc: Nikita Shubin <nikita.shubin@maquefel.me>
Signed-off-by: Johan Hovold <johan@kernel.org>
---
 drivers/spi/spi-ep93xx.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/spi/spi-ep93xx.c b/drivers/spi/spi-ep93xx.c
index db50018050e5..f716c9607be4 100644
--- a/drivers/spi/spi-ep93xx.c
+++ b/drivers/spi/spi-ep93xx.c
@@ -582,12 +582,14 @@ static int ep93xx_spi_setup_dma(struct device *dev, struct ep93xx_spi *espi)
 	espi->dma_rx = dma_request_chan(dev, "rx");
 	if (IS_ERR(espi->dma_rx)) {
 		ret = dev_err_probe(dev, PTR_ERR(espi->dma_rx), "rx DMA setup failed");
+		espi->dma_rx = NULL;
 		goto fail_free_page;
 	}
 
 	espi->dma_tx = dma_request_chan(dev, "tx");
 	if (IS_ERR(espi->dma_tx)) {
 		ret = dev_err_probe(dev, PTR_ERR(espi->dma_tx), "tx DMA setup failed");
+		espi->dma_tx = NULL;
 		goto fail_release_rx;
 	}
 
-- 
2.53.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] spi: ep93xx: fix error pointer deref after DMA setup failure
  2026-05-12  7:48 [PATCH] spi: ep93xx: fix error pointer deref after DMA setup failure Johan Hovold
@ 2026-05-12 11:31 ` Nikita Shubin
  2026-05-12 12:49 ` Mark Brown
  1 sibling, 0 replies; 3+ messages in thread
From: Nikita Shubin @ 2026-05-12 11:31 UTC (permalink / raw)
  To: Johan Hovold, Mark Brown, Alexander Sverdlin
  Cc: linux-spi, linux-kernel, stable

On Tue, 2026-05-12 at 09:48 +0200, Johan Hovold wrote:
> The driver falls back to PIO mode if DMA setup fails during probe.
> 
> Make sure to the clear the DMA channel pointers on setup failure to
> avoid dereferencing an error pointer on later probe errors or driver
> unbind.
> 
> This issue was flagged by Sashiko when reviewing a devres allocation
> conversion patch.
> 
> Fixes: e79e7c2df627 ("spi: ep93xx: add DT support for Cirrus EP93xx")
> Link:
> https://sashiko.dev/#/patchset/20260429091333.165363-1-johan%40kernel.org?part=10
> Cc: stable@vger.kernel.org	# 6.12
> Cc: Nikita Shubin <nikita.shubin@maquefel.me>
> Signed-off-by: Johan Hovold <johan@kernel.org>

Acked-by: Nikita Shubin <nikita.shubin@maquefel.me>

> ---
>  drivers/spi/spi-ep93xx.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/spi/spi-ep93xx.c b/drivers/spi/spi-ep93xx.c
> index db50018050e5..f716c9607be4 100644
> --- a/drivers/spi/spi-ep93xx.c
> +++ b/drivers/spi/spi-ep93xx.c
> @@ -582,12 +582,14 @@ static int ep93xx_spi_setup_dma(struct device
> *dev, struct ep93xx_spi *espi)
>  	espi->dma_rx = dma_request_chan(dev, "rx");
>  	if (IS_ERR(espi->dma_rx)) {
>  		ret = dev_err_probe(dev, PTR_ERR(espi->dma_rx), "rx
> DMA setup failed");
> +		espi->dma_rx = NULL;
>  		goto fail_free_page;
>  	}
>  
>  	espi->dma_tx = dma_request_chan(dev, "tx");
>  	if (IS_ERR(espi->dma_tx)) {
>  		ret = dev_err_probe(dev, PTR_ERR(espi->dma_tx), "tx
> DMA setup failed");
> +		espi->dma_tx = NULL;
>  		goto fail_release_rx;
>  	}
>  

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] spi: ep93xx: fix error pointer deref after DMA setup failure
  2026-05-12  7:48 [PATCH] spi: ep93xx: fix error pointer deref after DMA setup failure Johan Hovold
  2026-05-12 11:31 ` Nikita Shubin
@ 2026-05-12 12:49 ` Mark Brown
  1 sibling, 0 replies; 3+ messages in thread
From: Mark Brown @ 2026-05-12 12:49 UTC (permalink / raw)
  To: Johan Hovold; +Cc: linux-spi, linux-kernel, stable, Nikita Shubin

On Tue, 12 May 2026 09:48:49 +0200, Johan Hovold wrote:
> spi: ep93xx: fix error pointer deref after DMA setup failure

Applied to

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git for-7.1

Thanks!

[1/1] spi: ep93xx: fix error pointer deref after DMA setup failure
      https://git.kernel.org/broonie/spi/c/5e121a81667a

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-05-13  1:39 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-12  7:48 [PATCH] spi: ep93xx: fix error pointer deref after DMA setup failure Johan Hovold
2026-05-12 11:31 ` Nikita Shubin
2026-05-12 12:49 ` Mark Brown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox