From: Dave Jiang Date: Thu, 21 Jul 2016 19:40:52 +0000 (-0700) Subject: dmaengine: ioatdma: fix uninitialized array usage X-Git-Tag: v4.14-rc1~2349^2~10^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=2eab9b1a3006b4f7bf49c55ce23943170a0068db;p=platform%2Fkernel%2Flinux-rpi.git dmaengine: ioatdma: fix uninitialized array usage Static analysis showed that unitialized array is being used for compare. At line 850 when a dma_mapping_error() occurs, it jumps to dma_unmap. At this point, dma_srcs has not been initialized. However, the code after dma_unmap label checks dma_srcs for a comparison and thus is comparing to random garbage in the array. Given that when dest_dma is being mapped this is the first instance of mapping DMA memory and failed, there is really nothing to be cleaned up and thus should jump to free_resources label instead. Signed-off-by: Dave Jiang Signed-off-by: Vinod Koul --- diff --git a/drivers/dma/ioat/init.c b/drivers/dma/ioat/init.c index 7145f77..015f711 100644 --- a/drivers/dma/ioat/init.c +++ b/drivers/dma/ioat/init.c @@ -828,7 +828,7 @@ static int ioat_xor_val_self_test(struct ioatdma_device *ioat_dma) dest_dma = dma_map_page(dev, dest, 0, PAGE_SIZE, DMA_FROM_DEVICE); if (dma_mapping_error(dev, dest_dma)) - goto dma_unmap; + goto free_resources; for (i = 0; i < IOAT_NUM_SRC_TEST; i++) dma_srcs[i] = DMA_ERROR_CODE;