From patchwork Wed Nov 5 18:37:00 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 5237361 Return-Path: X-Original-To: patchwork-dmaengine@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 1FABC9F472 for ; Wed, 5 Nov 2014 18:37:08 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 469D42012E for ; Wed, 5 Nov 2014 18:37:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 6A4DE20154 for ; Wed, 5 Nov 2014 18:37:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750796AbaKEShF (ORCPT ); Wed, 5 Nov 2014 13:37:05 -0500 Received: from galahad.ideasonboard.com ([185.26.127.97]:56542 "EHLO galahad.ideasonboard.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751264AbaKEShE (ORCPT ); Wed, 5 Nov 2014 13:37:04 -0500 Received: from avalon.ideasonboard.com (unknown [109.140.184.82]) by galahad.ideasonboard.com (Postfix) with ESMTPSA id 10A5920AE7; Wed, 5 Nov 2014 19:34:45 +0100 (CET) From: Laurent Pinchart To: dmaengine@vger.kernel.org Cc: Vinod Koul , Srikanth Thokala Subject: [PATCH 1/3] dma: xilinx: vdma: Check if the segment list is empty in a descriptor Date: Wed, 5 Nov 2014 20:37:00 +0200 Message-Id: <1415212622-5094-2-git-send-email-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.0.4 In-Reply-To: <1415212622-5094-1-git-send-email-laurent.pinchart@ideasonboard.com> References: <1415212622-5094-1-git-send-email-laurent.pinchart@ideasonboard.com> Sender: dmaengine-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: dmaengine@vger.kernel.org X-Spam-Status: No, score=-7.5 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Srikanth Thokala 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 Signed-off-by: Michal Simek --- drivers/dma/xilinx/xilinx_vdma.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/dma/xilinx/xilinx_vdma.c b/drivers/dma/xilinx/xilinx_vdma.c index a6e6476..1093794 100644 --- a/drivers/dma/xilinx/xilinx_vdma.c +++ b/drivers/dma/xilinx/xilinx_vdma.c @@ -971,9 +971,11 @@ xilinx_vdma_dma_prep_interleaved(struct dma_chan *dchan, hw->buf_addr = xt->src_start; /* Link the previous next descriptor to current */ - prev = list_last_entry(&desc->segments, - struct xilinx_vdma_tx_segment, node); - prev->hw.next_desc = segment->phys; + if (!list_empty(&desc->segments)) { + prev = list_last_entry(&desc->segments, + struct xilinx_vdma_tx_segment, node); + prev->hw.next_desc = segment->phys; + } /* Insert the segment into the descriptor segments list. */ list_add_tail(&segment->node, &desc->segments);