Skip to content

Commit 5de7ed0

Browse files
Dan Carpenterbroonie
authored andcommitted
spi: rockchip: potential NULL dereference on error
We were calling dma_release_channel(rs->dma_tx.ch) when "rs->dma_tx.ch" is potentially NULL. There is actually a call to that in the unwind code at the bottom of the function so we can just re-arrange this a bit and remove the call. Also there is no need to set rs->dma_tx.ch to NULL on this error path. Fixes: e4c0e06 ('spi: rockchip: fix probe deferral handling') Signed-off-by: Dan Carpenter <[email protected]> Signed-off-by: Mark Brown <[email protected]>
1 parent 3d277b1 commit 5de7ed0

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

drivers/spi/spi-rockchip.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -744,10 +744,8 @@ static int rockchip_spi_probe(struct platform_device *pdev)
744744
rs->dma_rx.ch = dma_request_chan(rs->dev, "rx");
745745
if (IS_ERR(rs->dma_rx.ch)) {
746746
if (PTR_ERR(rs->dma_rx.ch) == -EPROBE_DEFER) {
747-
dma_release_channel(rs->dma_tx.ch);
748-
rs->dma_tx.ch = NULL;
749747
ret = -EPROBE_DEFER;
750-
goto err_get_fifo_len;
748+
goto err_free_dma_tx;
751749
}
752750
dev_warn(rs->dev, "Failed to request RX DMA channel\n");
753751
rs->dma_rx.ch = NULL;
@@ -775,10 +773,11 @@ static int rockchip_spi_probe(struct platform_device *pdev)
775773

776774
err_register_master:
777775
pm_runtime_disable(&pdev->dev);
778-
if (rs->dma_tx.ch)
779-
dma_release_channel(rs->dma_tx.ch);
780776
if (rs->dma_rx.ch)
781777
dma_release_channel(rs->dma_rx.ch);
778+
err_free_dma_tx:
779+
if (rs->dma_tx.ch)
780+
dma_release_channel(rs->dma_tx.ch);
782781
err_get_fifo_len:
783782
clk_disable_unprepare(rs->spiclk);
784783
err_spiclk_enable:

0 commit comments

Comments
 (0)