From patchwork Mon Sep 29 20:27:52 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 4998861 Return-Path: X-Original-To: patchwork-dmaengine@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id C8ED9BEEA6 for ; Mon, 29 Sep 2014 20:28:14 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 07D1D201FB for ; Mon, 29 Sep 2014 20:28:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 29A3E201EC for ; Mon, 29 Sep 2014 20:28:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754705AbaI2U2I (ORCPT ); Mon, 29 Sep 2014 16:28:08 -0400 Received: from galahad.ideasonboard.com ([185.26.127.97]:49618 "EHLO galahad.ideasonboard.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751215AbaI2U2H (ORCPT ); Mon, 29 Sep 2014 16:28:07 -0400 Received: from avalon.ideasonboard.com (dsl-hkibrasgw3-50ddcc-40.dhcp.inet.fi [80.221.204.40]) by galahad.ideasonboard.com (Postfix) with ESMTPSA id 88DF520CB4; Mon, 29 Sep 2014 22:26:36 +0200 (CEST) From: Laurent Pinchart To: linux-media@vger.kernel.org Cc: Michal Simek , Chris Kohn , Hyun Kwon , Srikanth Thokala , dmaengine@vger.kernel.org Subject: [PATCH 06/11] dma: xilinx: vdma: Check if the segment list is empty in a descriptor Date: Mon, 29 Sep 2014 23:27:52 +0300 Message-Id: <1412022477-28749-7-git-send-email-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 1.8.5.5 In-Reply-To: <1412022477-28749-1-git-send-email-laurent.pinchart@ideasonboard.com> References: <1412022477-28749-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.7 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(-) Cc: dmaengine@vger.kernel.org diff --git a/drivers/dma/xilinx/xilinx_vdma.c b/drivers/dma/xilinx/xilinx_vdma.c index 42a13e8..8e9f2a6 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);