]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
spi: qup: fix error pointer deref after DMA setup failure
authorJohan Hovold <johan@kernel.org>
Tue, 12 May 2026 07:43:34 +0000 (09:43 +0200)
committerMark Brown <broonie@kernel.org>
Mon, 18 May 2026 16:36:26 +0000 (17:36 +0100)
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 (or attempting to release a channel
a second time) on later probe errors or driver unbind.

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

Fixes: 612762e82ae6 ("spi: qup: Add DMA capabilities")
Link: https://sashiko.dev/#/patchset/20260505072909.618363-1-johan%40kernel.org?part=4
Cc: stable@vger.kernel.org # 4.1
Signed-off-by: Johan Hovold <johan@kernel.org>
Link: https://patch.msgid.link/20260512074334.914735-1-johan@kernel.org
Signed-off-by: Mark Brown <broonie@kernel.org>
drivers/spi/spi-qup.c

index 45d9b4cb75e4aaaf5b508f9c456b6b612ca03012..50bb7701b9d5a697c8b3155780432dad66255d22 100644 (file)
@@ -996,8 +996,11 @@ static int spi_qup_init_dma(struct spi_controller *host, resource_size_t base)
 
 err:
        dma_release_channel(host->dma_tx);
+       host->dma_tx = NULL;
 err_tx:
        dma_release_channel(host->dma_rx);
+       host->dma_rx = NULL;
+
        return ret;
 }