Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2ec7e2e7 authored by Sachin Kamat's avatar Sachin Kamat Committed by Vinod Koul
Browse files

dma: ste_dma40: Fix potential null pointer dereference



kcalloc can return NULL. Check the pointer before dereferencing.

Signed-off-by: default avatarSachin Kamat <sachin.kamat@linaro.org>
Signed-off-by: default avatarVinod Koul <vinod.koul@intel.com>
parent cbbe13ea
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -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;