Skip to content

Commit 075812e

Browse files
krzkbroonie
authored andcommitted
spi: atmel-quadspi: Fix printed error code during DMA setup
On dma_request_chan() failure driver NULL-ifies the 'rx_chan' and immediately uses it as PTR_ERR() so dev_err_probe() prints incorrect error code. Rework the code so proper error code will be printed and NULL-ifying of 'rx_chan' will happen in common error handling block (failure of DMA setup is not fatal for the driver and further code depends on 'rx_chan' being non-NULL for DMA operations). Reported by Smatch: drivers/spi/atmel-quadspi.c:1287 atmel_qspi_dma_init() warn: passing zero to 'PTR_ERR' Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org> Link: https://patch.msgid.link/20250501-n-smatch-fixes-v2-1-d2ad9c1f2e67@linaro.org Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent 233d740 commit 075812e

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

drivers/spi/atmel-quadspi.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1287,9 +1287,9 @@ static int atmel_qspi_dma_init(struct spi_controller *ctrl)
12871287

12881288
aq->rx_chan = dma_request_chan(&aq->pdev->dev, "rx");
12891289
if (IS_ERR(aq->rx_chan)) {
1290-
aq->rx_chan = NULL;
1291-
return dev_err_probe(&aq->pdev->dev, PTR_ERR(aq->rx_chan),
1292-
"RX DMA channel is not available\n");
1290+
ret = dev_err_probe(&aq->pdev->dev, PTR_ERR(aq->rx_chan),
1291+
"RX DMA channel is not available\n");
1292+
goto null_rx_chan;
12931293
}
12941294

12951295
aq->tx_chan = dma_request_chan(&aq->pdev->dev, "tx");
@@ -1310,8 +1310,9 @@ static int atmel_qspi_dma_init(struct spi_controller *ctrl)
13101310

13111311
release_rx_chan:
13121312
dma_release_channel(aq->rx_chan);
1313-
aq->rx_chan = NULL;
13141313
aq->tx_chan = NULL;
1314+
null_rx_chan:
1315+
aq->rx_chan = NULL;
13151316
return ret;
13161317
}
13171318

0 commit comments

Comments
 (0)