aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArnd Bergmann <arnd@arndb.de>2016-06-13 11:07:33 -0400
committerVinod Koul <vinod.koul@intel.com>2016-06-13 13:01:42 -0400
commitf67c3bdabbab47555232f1b883d4758792dd2bc4 (patch)
tree05c6320302e7ee68e611c2cd67aca5fc37214242
parente167a0b6dc49cb3694fea888560aa462532951dd (diff)
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>
-rw-r--r--drivers/dma/xilinx/xilinx_vdma.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/drivers/dma/xilinx/xilinx_vdma.c b/drivers/dma/xilinx/xilinx_vdma.c
index 0af0cf4b5f2e..914268bc9990 100644
--- a/drivers/dma/xilinx/xilinx_vdma.c
+++ b/drivers/dma/xilinx/xilinx_vdma.c
@@ -1745,8 +1745,14 @@ static struct dma_async_tx_descriptor *xilinx_dma_prep_dma_cyclic(
1745 int i; 1745 int i;
1746 u32 reg; 1746 u32 reg;
1747 1747
1748 if (!period_len)
1749 return NULL;
1750
1748 num_periods = buf_len / period_len; 1751 num_periods = buf_len / period_len;
1749 1752
1753 if (!num_periods)
1754 return NULL;
1755
1750 if (!is_slave_direction(direction)) 1756 if (!is_slave_direction(direction))
1751 return NULL; 1757 return NULL;
1752 1758