diff options
author | Dan Carpenter <dan.carpenter@oracle.com> | 2016-05-04 02:25:46 -0400 |
---|---|---|
committer | Mark Brown <broonie@kernel.org> | 2016-05-04 09:41:56 -0400 |
commit | 5de7ed0c980c4bcfd8ea5c0b84a61b76df7d6c08 (patch) | |
tree | 338afa10016cc76221713c59e58625d3d6444279 | |
parent | 3d277b177918cd26215732fc23af0783ab4b37dd (diff) |
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: e4c0e06f949b ('spi: rockchip: fix probe deferral handling')
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
-rw-r--r-- | drivers/spi/spi-rockchip.c | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/drivers/spi/spi-rockchip.c b/drivers/spi/spi-rockchip.c index 6c6c0013ec7a..cd89682065b9 100644 --- a/drivers/spi/spi-rockchip.c +++ b/drivers/spi/spi-rockchip.c | |||
@@ -744,10 +744,8 @@ static int rockchip_spi_probe(struct platform_device *pdev) | |||
744 | rs->dma_rx.ch = dma_request_chan(rs->dev, "rx"); | 744 | rs->dma_rx.ch = dma_request_chan(rs->dev, "rx"); |
745 | if (IS_ERR(rs->dma_rx.ch)) { | 745 | if (IS_ERR(rs->dma_rx.ch)) { |
746 | if (PTR_ERR(rs->dma_rx.ch) == -EPROBE_DEFER) { | 746 | if (PTR_ERR(rs->dma_rx.ch) == -EPROBE_DEFER) { |
747 | dma_release_channel(rs->dma_tx.ch); | ||
748 | rs->dma_tx.ch = NULL; | ||
749 | ret = -EPROBE_DEFER; | 747 | ret = -EPROBE_DEFER; |
750 | goto err_get_fifo_len; | 748 | goto err_free_dma_tx; |
751 | } | 749 | } |
752 | dev_warn(rs->dev, "Failed to request RX DMA channel\n"); | 750 | dev_warn(rs->dev, "Failed to request RX DMA channel\n"); |
753 | rs->dma_rx.ch = NULL; | 751 | rs->dma_rx.ch = NULL; |
@@ -775,10 +773,11 @@ static int rockchip_spi_probe(struct platform_device *pdev) | |||
775 | 773 | ||
776 | err_register_master: | 774 | err_register_master: |
777 | pm_runtime_disable(&pdev->dev); | 775 | pm_runtime_disable(&pdev->dev); |
778 | if (rs->dma_tx.ch) | ||
779 | dma_release_channel(rs->dma_tx.ch); | ||
780 | if (rs->dma_rx.ch) | 776 | if (rs->dma_rx.ch) |
781 | dma_release_channel(rs->dma_rx.ch); | 777 | 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); | ||
782 | err_get_fifo_len: | 781 | err_get_fifo_len: |
783 | clk_disable_unprepare(rs->spiclk); | 782 | clk_disable_unprepare(rs->spiclk); |
784 | err_spiclk_enable: | 783 | err_spiclk_enable: |