Skip to content

Commit

Permalink
spi: dw-mid: avoid potential NULL dereference
Browse files Browse the repository at this point in the history
When DMA descriptor allocation fails we should not try to assign any fields in
the bad descriptor. The patch adds the necessary checks for that.

Fixes: 7063c0d (spi/dw_spi: add DMA support)
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
Cc: stable@vger.kernel.org
  • Loading branch information
Andy Shevchenko authored and Mark Brown committed Mar 6, 2015
1 parent 9d239d3 commit c9dafb2
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions drivers/spi/spi-dw-mid.c
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,9 @@ static struct dma_async_tx_descriptor *dw_spi_dma_prepare_tx(struct dw_spi *dws)
1,
DMA_MEM_TO_DEV,
DMA_PREP_INTERRUPT | DMA_CTRL_ACK);
if (!txdesc)
return NULL;

txdesc->callback = dw_spi_dma_tx_done;
txdesc->callback_param = dws;

Expand Down Expand Up @@ -184,6 +187,9 @@ static struct dma_async_tx_descriptor *dw_spi_dma_prepare_rx(struct dw_spi *dws)
1,
DMA_DEV_TO_MEM,
DMA_PREP_INTERRUPT | DMA_CTRL_ACK);
if (!rxdesc)
return NULL;

rxdesc->callback = dw_spi_dma_rx_done;
rxdesc->callback_param = dws;

Expand Down

0 comments on commit c9dafb2

Please sign in to comment.