[PATCH 6.12.y 2/2] spi: cadence-quadspi: release DMA channel on probe failure

"Diogo Ivo (Schneider Electric)" <[email protected]>
Newsgroups org.kernel.vger.linux-spi,org.kernel.vger.linux-kernel,org.kernel.vger.stable
Message-ID <[email protected]>
When spi_register_controller() fails in cqspi_probe(), the DMA channel
acquired via cqspi_request_mmap_dma() is not released, leaking the channel.
Add a dedicated error label to release the DMA channel before the
existing runtime PM teardown path.

This fix is one part of upstream commit f18c8cfa4f1a ("spi: cadence-qspi:
Fix probe error path and remove").

Fixes: b85815675fc5 ("spi: cadence-quadspi: fix cleanup of rx_chan on failure paths")
Cc: [email protected]
Signed-off-by: Diogo Ivo (Schneider Electric) <[email protected]>
---
 drivers/spi/spi-cadence-quadspi.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/spi/spi-cadence-quadspi.c b/drivers/spi/spi-cadence-quadspi.c
index d749dee54015..66304664a1cf 100644
--- a/drivers/spi/spi-cadence-quadspi.c
+++ b/drivers/spi/spi-cadence-quadspi.c
@@ -1982,14 +1982,17 @@ static int cqspi_probe(struct platform_device *pdev)
 	ret = spi_register_controller(host);
 	if (ret) {
 		dev_err(&pdev->dev, "failed to register SPI ctlr %d\n", ret);
-		goto disable_rpm;
+		goto release_dma_chan;
 	}
 
 	pm_runtime_mark_last_busy(dev);
 	pm_runtime_put_autosuspend(dev);
 
 	return 0;
-disable_rpm:
+release_dma_chan:
+	if (cqspi->rx_chan)
+		dma_release_channel(cqspi->rx_chan);
+
 	pm_runtime_put_noidle(dev);
 	pm_runtime_dont_use_autosuspend(dev);
 	pm_runtime_disable(dev);

-- 
2.55.0
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.