diff options
author | Scott Ellis <scott@jumpnowtek.com> | 2010-05-24 14:20:27 +0000 |
---|---|---|
committer | Grant Likely <grant.likely@secretlab.ca> | 2010-05-25 00:23:15 -0600 |
commit | 99f1a43f436a6a92d15bddfeb65f3a920c8b88d3 (patch) | |
tree | 3aef4ab77ca8d3bb72f0eb0d3bbd9842e25948e6 /drivers/spi | |
parent | 4743a0f88c4000dfa3c422ecc4d750d3a3410550 (diff) | |
download | linux-3.10-99f1a43f436a6a92d15bddfeb65f3a920c8b88d3.tar.gz linux-3.10-99f1a43f436a6a92d15bddfeb65f3a920c8b88d3.tar.bz2 linux-3.10-99f1a43f436a6a92d15bddfeb65f3a920c8b88d3.zip |
spi/omap2_mcspi: Check params before dereference or use
Check spi->chip_select for range before use.
Signed-off-by: Scott Ellis <scott@jumpnowtek.com>
Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
Diffstat (limited to 'drivers/spi')
-rw-r--r-- | drivers/spi/omap2_mcspi.c | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/drivers/spi/omap2_mcspi.c b/drivers/spi/omap2_mcspi.c index 6df85537bd1..b3a94ca0a75 100644 --- a/drivers/spi/omap2_mcspi.c +++ b/drivers/spi/omap2_mcspi.c @@ -834,7 +834,6 @@ static void omap2_mcspi_cleanup(struct spi_device *spi) struct omap2_mcspi_cs *cs; mcspi = spi_master_get_devdata(spi->master); - mcspi_dma = &mcspi->dma_channels[spi->chip_select]; if (spi->controller_state) { /* Unlink controller state from context save list */ @@ -844,13 +843,17 @@ static void omap2_mcspi_cleanup(struct spi_device *spi) kfree(spi->controller_state); } - if (mcspi_dma->dma_rx_channel != -1) { - omap_free_dma(mcspi_dma->dma_rx_channel); - mcspi_dma->dma_rx_channel = -1; - } - if (mcspi_dma->dma_tx_channel != -1) { - omap_free_dma(mcspi_dma->dma_tx_channel); - mcspi_dma->dma_tx_channel = -1; + if (spi->chip_select < spi->master->num_chipselect) { + mcspi_dma = &mcspi->dma_channels[spi->chip_select]; + + if (mcspi_dma->dma_rx_channel != -1) { + omap_free_dma(mcspi_dma->dma_rx_channel); + mcspi_dma->dma_rx_channel = -1; + } + if (mcspi_dma->dma_tx_channel != -1) { + omap_free_dma(mcspi_dma->dma_tx_channel); + mcspi_dma->dma_tx_channel = -1; + } } } |