dmaengine: xilinx: vdma: Check if the segment list is empty in a descriptor

The segment list in a descriptor should be checked for empty, else
it will try to access invalid address for the first call.  This
patch fixes this issue.

Signed-off-by: Srikanth Thokala <sthokal@xilinx.com>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
Signed-off-by: Vinod Koul <vinod.koul@intel.com>
This commit is contained in:
Srikanth Thokala 2014-11-05 20:37:00 +02:00 committed by Vinod Koul
parent cd166280b7
commit 049c0d577d

View file

@ -971,9 +971,11 @@ xilinx_vdma_dma_prep_interleaved(struct dma_chan *dchan,
hw->buf_addr = xt->src_start; hw->buf_addr = xt->src_start;
/* Link the previous next descriptor to current */ /* Link the previous next descriptor to current */
prev = list_last_entry(&desc->segments, if (!list_empty(&desc->segments)) {
struct xilinx_vdma_tx_segment, node); prev = list_last_entry(&desc->segments,
prev->hw.next_desc = segment->phys; struct xilinx_vdma_tx_segment, node);
prev->hw.next_desc = segment->phys;
}
/* Insert the segment into the descriptor segments list. */ /* Insert the segment into the descriptor segments list. */
list_add_tail(&segment->node, &desc->segments); list_add_tail(&segment->node, &desc->segments);