Skip to content

Commit

Permalink
dma: ste_dma40: Fix potential null pointer dereference
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Sachin Kamat authored and Vinod Koul committed Sep 2, 2013
1 parent cbbe13e commit 2ec7e2e
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions drivers/dma/ste_dma40.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 2ec7e2e

Please sign in to comment.