From: Sachin Kamat Date: Mon, 2 Sep 2013 08:14:59 +0000 (+0530) Subject: dma: ste_dma40: Fix potential null pointer dereference X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=2ec7e2e7b5f41a09264abc6dbcfd3fdc9a1edfd5;p=GitHub%2FLineageOS%2FG12%2Fandroid_kernel_amlogic_linux-4.9.git dma: ste_dma40: Fix potential null pointer dereference kcalloc can return NULL. Check the pointer before dereferencing. Signed-off-by: Sachin Kamat Signed-off-by: Vinod Koul --- 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;