All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] spi: sprd: fix error pointer deref after DMA setup failure
@ 2026-05-12  7:47 Johan Hovold
  2026-05-18 16:40 ` Mark Brown
  0 siblings, 1 reply; 2+ messages in thread
From: Johan Hovold @ 2026-05-12  7:47 UTC (permalink / raw)
  To: Mark Brown
  Cc: Orson Zhai, Baolin Wang, Chunyan Zhang, Lanqing Liu, linux-spi,
	linux-kernel, Johan Hovold, stable

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

Make sure to check the dma.enabled flag before trying to release the DMA
channels also on late probe errors to avoid dereferencing an error
pointer (or attempting to release a channel a second time).

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

Fixes: 386119bc7be9 ("spi: sprd: spi: sprd: Add DMA mode support")
Link: https://sashiko.dev/#/patchset/20260505072909.618363-1-johan%40kernel.org?part=10
Cc: stable@vger.kernel.org	# 5.1
Cc: Lanqing Liu <lanqing.liu@unisoc.com>
Signed-off-by: Johan Hovold <johan@kernel.org>
---

Note that this one is based on 7.1-rc3 and will cause a trivial conflict
with the devres allocation patch in spi/for-7.2 branch.

Let me know if your prefer a rebase on top of the conversion instead
(which will result in a similar context conflict when backporting).

Johan


 drivers/spi/spi-sprd.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/spi/spi-sprd.c b/drivers/spi/spi-sprd.c
index fd3fd0ce122c..acebf9c2e795 100644
--- a/drivers/spi/spi-sprd.c
+++ b/drivers/spi/spi-sprd.c
@@ -991,7 +991,8 @@ static int sprd_spi_probe(struct platform_device *pdev)
 disable_clk:
 	clk_disable_unprepare(ss->clk);
 release_dma:
-	sprd_spi_dma_release(ss);
+	if (ss->dma.enable)
+		sprd_spi_dma_release(ss);
 free_controller:
 	spi_controller_put(sctlr);
 
-- 
2.53.0


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

end of thread, other threads:[~2026-05-19  9:25 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-12  7:47 [PATCH] spi: sprd: fix error pointer deref after DMA setup failure Johan Hovold
2026-05-18 16:40 ` Mark Brown

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.