summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndy Shevchenko <andriy.shevchenko@linux.intel.com>2015-03-02 20:15:58 +0200
committerSasha Levin <sasha.levin@oracle.com>2015-03-28 09:49:22 -0400
commitf3aa910546efe131b46ee2b7721a473b7b6938bc (patch)
tree9a7d0db8888fe4baeb0108cbd19f6859d135e82e
parentfbafcf8fb1f46e46e8f5882be2fdf6428f6f6801 (diff)
spi: dw-mid: avoid potential NULL dereference
[ Upstream commit c9dafb27c84412fe4b17c3b94cc4ffeef5df1833 ] 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> Signed-off-by: Mark Brown <broonie@kernel.org> Cc: stable@vger.kernel.org Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
-rw-r--r--drivers/spi/spi-dw-mid.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/drivers/spi/spi-dw-mid.c b/drivers/spi/spi-dw-mid.c
index efff55537d8a..1417f96546ce 100644
--- a/drivers/spi/spi-dw-mid.c
+++ b/drivers/spi/spi-dw-mid.c
@@ -151,6 +151,9 @@ static int mid_spi_dma_transfer(struct dw_spi *dws, int cs_change)
1,
DMA_MEM_TO_DEV,
DMA_PREP_INTERRUPT | DMA_CTRL_ACK);
+ if (!txdesc)
+ return NULL;
+
txdesc->callback = dw_spi_dma_done;
txdesc->callback_param = dws;
@@ -173,6 +176,9 @@ static int mid_spi_dma_transfer(struct dw_spi *dws, int cs_change)
1,
DMA_DEV_TO_MEM,
DMA_PREP_INTERRUPT | DMA_CTRL_ACK);
+ if (!rxdesc)
+ return NULL;
+
rxdesc->callback = dw_spi_dma_done;
rxdesc->callback_param = dws;