summaryrefslogtreecommitdiffstats
path: root/drivers/dma/ste_dma40.c
diff options
context:
space:
mode:
authorSachin Kamat <sachin.kamat@linaro.org>2013-09-02 10:14:59 +0200
committerVinod Koul <vinod.koul@intel.com>2013-09-02 14:06:00 +0200
commit2ec7e2e7b5f41a09264abc6dbcfd3fdc9a1edfd5 (patch)
tree7f11738f7ea315d345702d4a0b2817cacfdced11 /drivers/dma/ste_dma40.c
parentdma: ste_dma40: Remove duplicate const (diff)
downloadlinux-2ec7e2e7b5f41a09264abc6dbcfd3fdc9a1edfd5.tar.xz
linux-2ec7e2e7b5f41a09264abc6dbcfd3fdc9a1edfd5.zip
dma: ste_dma40: Fix potential null pointer dereference
kcalloc can return NULL. Check the pointer before dereferencing. Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org> Signed-off-by: Vinod Koul <vinod.koul@intel.com>
Diffstat (limited to 'drivers/dma/ste_dma40.c')
-rw-r--r--drivers/dma/ste_dma40.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/drivers/dma/ste_dma40.c b/drivers/dma/ste_dma40.c
index df0a60656a8b..82d2b97ad942 100644
--- a/drivers/dma/ste_dma40.c
+++ b/drivers/dma/ste_dma40.c
@@ -2591,6 +2591,9 @@ dma40_prep_dma_cyclic(struct dma_chan *chan, dma_addr_t dma_addr,
int i;
sg = kcalloc(periods + 1, sizeof(struct scatterlist), GFP_NOWAIT);
+ if (!sg)
+ return NULL;
+
for (i = 0; i < periods; i++) {
sg_dma_address(&sg[i]) = dma_addr;
sg_dma_len(&sg[i]) = period_len;