Commit 99f1a43f authored by Scott Ellis's avatar Scott Ellis Committed by Grant Likely

spi/omap2_mcspi: Check params before dereference or use

Check spi->chip_select for range before use.
Signed-off-by: default avatarScott Ellis <scott@jumpnowtek.com>
Signed-off-by: default avatarGrant Likely <grant.likely@secretlab.ca>
parent 4743a0f8
...@@ -834,7 +834,6 @@ static void omap2_mcspi_cleanup(struct spi_device *spi) ...@@ -834,7 +834,6 @@ static void omap2_mcspi_cleanup(struct spi_device *spi)
struct omap2_mcspi_cs *cs; struct omap2_mcspi_cs *cs;
mcspi = spi_master_get_devdata(spi->master); mcspi = spi_master_get_devdata(spi->master);
mcspi_dma = &mcspi->dma_channels[spi->chip_select];
if (spi->controller_state) { if (spi->controller_state) {
/* Unlink controller state from context save list */ /* Unlink controller state from context save list */
...@@ -844,6 +843,9 @@ static void omap2_mcspi_cleanup(struct spi_device *spi) ...@@ -844,6 +843,9 @@ static void omap2_mcspi_cleanup(struct spi_device *spi)
kfree(spi->controller_state); kfree(spi->controller_state);
} }
if (spi->chip_select < spi->master->num_chipselect) {
mcspi_dma = &mcspi->dma_channels[spi->chip_select];
if (mcspi_dma->dma_rx_channel != -1) { if (mcspi_dma->dma_rx_channel != -1) {
omap_free_dma(mcspi_dma->dma_rx_channel); omap_free_dma(mcspi_dma->dma_rx_channel);
mcspi_dma->dma_rx_channel = -1; mcspi_dma->dma_rx_channel = -1;
...@@ -852,6 +854,7 @@ static void omap2_mcspi_cleanup(struct spi_device *spi) ...@@ -852,6 +854,7 @@ static void omap2_mcspi_cleanup(struct spi_device *spi)
omap_free_dma(mcspi_dma->dma_tx_channel); omap_free_dma(mcspi_dma->dma_tx_channel);
mcspi_dma->dma_tx_channel = -1; mcspi_dma->dma_tx_channel = -1;
} }
}
} }
static void omap2_mcspi_work(struct work_struct *work) static void omap2_mcspi_work(struct work_struct *work)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment