diff mbox

[v2,1/9] spi: dw-mid: avoid potential NULL dereference

Message ID 1425320166-13788-2-git-send-email-andriy.shevchenko@linux.intel.com (mailing list archive)
State Not Applicable
Headers show

Commit Message

Andy Shevchenko March 2, 2015, 6:15 p.m. UTC
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: 7063c0d942a1 (spi/dw_spi: add DMA support)
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/spi/spi-dw-mid.c | 6 ++++++
 1 file changed, 6 insertions(+)

Comments

Mark Brown March 6, 2015, 11:28 a.m. UTC | #1
On Mon, Mar 02, 2015 at 08:15:58PM +0200, Andy Shevchenko wrote:
> 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.

Applied, thanks.  The rest of the series all looks OK but it looks like
we should get patch 2 into stable like I said in reply to it - apply
that on fix/dw and then everything else on a merge of that and topic/dw.
Andy Shevchenko March 6, 2015, 12:53 p.m. UTC | #2
On Fri, 2015-03-06 at 11:28 +0000, Mark Brown wrote:
> On Mon, Mar 02, 2015 at 08:15:58PM +0200, Andy Shevchenko wrote:
> > 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.
> 
> Applied, thanks.  The rest of the series all looks OK but it looks like
> we should get patch 2 into stable like I said in reply to it - apply
> that on fix/dw 

Okay, I have resent it just in case.

> and then everything else on a merge of that and topic/dw.

Just to kindly remind that it has a dependency on two previous series,
one of them touches SPI core.
diff mbox

Patch

diff --git a/drivers/spi/spi-dw-mid.c b/drivers/spi/spi-dw-mid.c
index 8f68e82..a8a5ee3 100644
--- a/drivers/spi/spi-dw-mid.c
+++ b/drivers/spi/spi-dw-mid.c
@@ -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;
 
@@ -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;