dmaengine: xilinx: avoid memory corruption for device_prep_dma_memcpy()
authorAkinobu Mita <akinobu.mita@gmail.com>
Mon, 13 Mar 2017 15:59:12 +0000 (00:59 +0900)
committerVinod Koul <vinod.koul@intel.com>
Tue, 14 Mar 2017 10:44:29 +0000 (16:14 +0530)
commitdb6a3d03e22f3daf09d8d1532bd1d3747062a561
treee09e76c5ea1083b22d8ffedc2a98206cb78713a5
parent676f9c26c330d087125769200bcf080c3c88488e
dmaengine: xilinx: avoid memory corruption for device_prep_dma_memcpy()

The device_prep_dma_memcpy() callback for this driver allocates a new
xilinx_dma_tx_descriptor whose TX segments list is initialized as empty,
but then gets invalid TX segment pointer by list_last_entry() from the
empty TX segments list and memory corruption happens by the attempt to
update the next descriptor in invalid TX segment pointer.

This removes unnecessary memory access for nonexistent tail TX segment
which causes memory corruption.

Cc: Vinod Koul <vinod.koul@intel.com>
Cc: Kedareswara rao Appana <appana.durga.rao@xilinx.com>
Cc: Michal Simek <monstr@monstr.eu>
Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Signed-off-by: Vinod Koul <vinod.koul@intel.com>
drivers/dma/xilinx/xilinx_dma.c