]> git.karo-electronics.de Git - linux-beck.git/commit
dmaengine: xilinx-vdma: add some sanity checks
authorArnd Bergmann <arnd@arndb.de>
Mon, 13 Jun 2016 15:07:33 +0000 (17:07 +0200)
committerVinod Koul <vinod.koul@intel.com>
Mon, 13 Jun 2016 17:01:42 +0000 (22:31 +0530)
commitf67c3bdabbab47555232f1b883d4758792dd2bc4
tree05c6320302e7ee68e611c2cd67aca5fc37214242
parente167a0b6dc49cb3694fea888560aa462532951dd
dmaengine: xilinx-vdma: add some sanity checks

The newly added xilinx_dma_prep_dma_cyclic function sometimes causes
a gcc warning about the use of the segment function in case
we never run into the inner loop of the function:

dma/xilinx/xilinx_vdma.c: In function 'xilinx_dma_prep_dma_cyclic':
dma/xilinx/xilinx_vdma.c:1808:23: error: 'segment' may be used uninitialized in this function [-Werror=maybe-uninitialized]
   segment->hw.control |= XILINX_DMA_BD_SOP;

This can only happen if the period len is zero (which would cause other
problems earlier), or if the buffer is shorter than a period. Neither
of them should ever happen, but by adding an explicit check for these two
cases, we can abort in a more controlled way, and the compiler is
able to see that we never use uninitialized data.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Vinod Koul <vinod.koul@intel.com>
drivers/dma/xilinx/xilinx_vdma.c