Skip to content

Commit c9dafb2

Browse files
andy-shevbroonie
authored andcommitted
spi: dw-mid: avoid potential NULL dereference
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
1 parent 9d239d3 commit c9dafb2

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

drivers/spi/spi-dw-mid.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,9 @@ static struct dma_async_tx_descriptor *dw_spi_dma_prepare_tx(struct dw_spi *dws)
139139
1,
140140
DMA_MEM_TO_DEV,
141141
DMA_PREP_INTERRUPT | DMA_CTRL_ACK);
142+
if (!txdesc)
143+
return NULL;
144+
142145
txdesc->callback = dw_spi_dma_tx_done;
143146
txdesc->callback_param = dws;
144147

@@ -184,6 +187,9 @@ static struct dma_async_tx_descriptor *dw_spi_dma_prepare_rx(struct dw_spi *dws)
184187
1,
185188
DMA_DEV_TO_MEM,
186189
DMA_PREP_INTERRUPT | DMA_CTRL_ACK);
190+
if (!rxdesc)
191+
return NULL;
192+
187193
rxdesc->callback = dw_spi_dma_rx_done;
188194
rxdesc->callback_param = dws;
189195

0 commit comments

Comments
 (0)