From 45f0bbdafd26d6d772172563b30bff561cec9133 Mon Sep 17 00:00:00 2001 From: Marek Vasut Date: Mon, 5 Oct 2020 15:22:29 +0200 Subject: spi: imx: Fix freeing of DMA channels if spi_bitbang_start() fails If the SPI controller has has_dmamode = true and spi_bitbang_start() fails in spi_imx_probe(), then the driver must release the DMA channels acquired in spi_imx_sdma_init() by calling spi_imx_sdma_exit() in the fail path. Fixes: f62caccd12c1 ("spi: spi-imx: add DMA support") Signed-off-by: Marek Vasut Cc: Fabio Estevam Cc: Mark Brown Cc: NXP Linux Team Cc: Robin Gong Cc: Shawn Guo Link: https://lore.kernel.org/r/20201005132229.513119-1-marex@denx.de Signed-off-by: Mark Brown --- drivers/spi/spi-imx.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'drivers/spi') diff --git a/drivers/spi/spi-imx.c b/drivers/spi/spi-imx.c index 38a5f1304cec..e38e5ad3c706 100644 --- a/drivers/spi/spi-imx.c +++ b/drivers/spi/spi-imx.c @@ -1707,7 +1707,7 @@ static int spi_imx_probe(struct platform_device *pdev) ret = spi_bitbang_start(&spi_imx->bitbang); if (ret) { dev_err(&pdev->dev, "bitbang start failed with %d\n", ret); - goto out_runtime_pm_put; + goto out_bitbang_start; } dev_info(&pdev->dev, "probed\n"); @@ -1717,6 +1717,9 @@ static int spi_imx_probe(struct platform_device *pdev) return ret; +out_bitbang_start: + if (spi_imx->devtype_data->has_dmamode) + spi_imx_sdma_exit(spi_imx); out_runtime_pm_put: pm_runtime_dont_use_autosuspend(spi_imx->dev); pm_runtime_put_sync(spi_imx->dev); -- cgit v1.2.3