Received: by 2002:a25:f815:0:0:0:0:0 with SMTP id u21csp499599ybd; Sat, 29 Jun 2019 01:22:31 -0700 (PDT) X-Google-Smtp-Source: APXvYqy4tyINwBg5pP9da/Etg2WCIdYDHVRj5jbNsa46FPstYYpFdnQZS4dG+Az2dvDmQsVHY8rW X-Received: by 2002:a17:902:748c:: with SMTP id h12mr10696900pll.208.1561796551829; Sat, 29 Jun 2019 01:22:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561796551; cv=none; d=google.com; s=arc-20160816; b=H931XMjLbqpaCJrOkyD+LT14QgF6lX36qvXgnF0aNbLI00po2ob4M5m6N9Z84B40AL TKk2k+cNqFDUz5u0TghE4aKnqc8ZEqF3F6CG2fZ4HdP844gYab2wGGImV9szY+mZXqKc a7Vxy8pIFtbNbKecxdAXlBZId4f5wGEhTu9FHkafgZMeN53KcnuupTxGMXXE4f3R2RFa 7c/5+/DGh4MM/yXMU3M2JgI2Bt9RRjZcyXNLqdGZsUAarQ7rV0SvOWJNCySEZJVF2FAw EDq6g/sK2uI4btXF3SEFnqTmesQ63WyUN8A01eFbU7+qwanDbF3oVJhZsKiwlSv5HX+W e5CQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature; bh=HB5G4BCyKAU7NWh04NXHQUYQWJo7mRMg3f1DS79X9is=; b=lREchXuJc+WSVfu+FsiFya5B3ipGP/0prxr6qI1n8xCY4CHot6PV4xmv2kUzq5PJFu hnKF1yYbRcf97usdVNPXO/FVpjENAfGdXDQLsjCw5olu4+kHxtwkWoAu9lpqfMhIFUQc yc+QgQVlZ0XeDZ6GnB8AaBsrH9GriwqMcqc+JTN0d5KE6UQzQri9F8tsgfknzCufzfzg 4b8u90FgpZR4Qhnh2rUV/UQaucnWRZbHJT2wqfsL+2DRyVYbDEF2KqadQi2pEMjwCSZn BSFFlaICYKvFHlND5YNtrYTJVU2YqTcSKOa3Jj1nBnYL9UYPQ5CCtV4f0Alx3/RUCCXl HTGQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=U+sD4Tg2; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o2si5137596pfg.136.2019.06.29.01.21.59; Sat, 29 Jun 2019 01:22:31 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=U+sD4Tg2; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726839AbfF2IVo (ORCPT + 99 others); Sat, 29 Jun 2019 04:21:44 -0400 Received: from mail-pf1-f193.google.com ([209.85.210.193]:37776 "EHLO mail-pf1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726766AbfF2IVo (ORCPT ); Sat, 29 Jun 2019 04:21:44 -0400 Received: by mail-pf1-f193.google.com with SMTP id 19so4132966pfa.4; Sat, 29 Jun 2019 01:21:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=HB5G4BCyKAU7NWh04NXHQUYQWJo7mRMg3f1DS79X9is=; b=U+sD4Tg2i5EmnQ+E96oYuHmFfjRIZFhu+ImSjldFv+pp7bnarxQt4kZTlckg4DVX+M 5BwiyO9vyxW50aW05AoE/XIReZ9UkFMhsaXqrral2F+wzcVqDlYG9Mvy5WHbXw3EVJDh O+MEOuUIm8CeKDhIpzNb9pUSquazzH3bdV8LKIxTfBVuq8knnPvwv2H4AHzKPX2lgP4s trkpZ1ybjg/Y1kuSq/ywv3KuZTsKx+BT4RNyIxMJxKYktCp2UZVQyYwlHdkJpOF55bVO qgTm4y/L71e3PxcXX0+KKUtPt/aEITyjaj+U13dkDaAkNQB52CqYfAurITZQgPSEwS/+ iYYA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=HB5G4BCyKAU7NWh04NXHQUYQWJo7mRMg3f1DS79X9is=; b=GvsMbNdKXv/hGaCFh45x2DeiIZnhv2PDkV7YHMYejqqkTNRIO43fmufrSVx/p10P53 FiREzKoZj7HgDFVShF0+e6Wws8v0ElPcP+a7yRr+QeeYTSkrO7iSS+3rvhLNTof4YiTw 0fhwF7Poazp/HUnmU4+4U3Ul072Z1hOdEhTRcAxP4jgpnCI6wPVBC5C8SLltcgVRvbAw BuNxxj3EVlkY7Wf1OKOwJKdcc4xYKfN0VaSjwRfut2aiYpFgZABhLvIPl1XupMIdBnYt 1e6Sx8zUCPxYAglPPT86rRJMVnuMOLmx2FRWZ99ZtOzjXczk7bUUh/eUaMsxSMZ9wxCS 33ag== X-Gm-Message-State: APjAAAVPlu3TTwLg1uysEYc4/0JOYuUiYDvoPvCAFwke20yt3ai8QChK rDZRRF+e376RsKmBBRzt0XvvJKYacYU= X-Received: by 2002:a17:90a:228b:: with SMTP id s11mr17710124pjc.23.1561796503508; Sat, 29 Jun 2019 01:21:43 -0700 (PDT) Received: from localhost.localdomain ([219.91.196.157]) by smtp.googlemail.com with ESMTPSA id 27sm3834610pgt.6.2019.06.29.01.21.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 29 Jun 2019 01:21:42 -0700 (PDT) From: Raag Jadav To: dmaengine@vger.kernel.org, Vinod Koul Cc: Ludovic Desroches , Dan Williams , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Raag Jadav Subject: [PATCH] dmaengine: at_xdmac: check for non-empty xfers_list before invoking callback Date: Sat, 29 Jun 2019 13:50:48 +0530 Message-Id: <1561796448-3321-1-git-send-email-raagjadav@gmail.com> X-Mailer: git-send-email 2.7.4 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org tx descriptor retrieved from an empty xfers_list may not have valid pointers to the callback functions. Avoid calling dmaengine_desc_get_callback_invoke if xfers_list is empty. Signed-off-by: Raag Jadav --- drivers/dma/at_xdmac.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/drivers/dma/at_xdmac.c b/drivers/dma/at_xdmac.c index 627ef3e..b58ac72 100644 --- a/drivers/dma/at_xdmac.c +++ b/drivers/dma/at_xdmac.c @@ -1568,11 +1568,14 @@ static void at_xdmac_handle_cyclic(struct at_xdmac_chan *atchan) struct at_xdmac_desc *desc; struct dma_async_tx_descriptor *txd; - desc = list_first_entry(&atchan->xfers_list, struct at_xdmac_desc, xfer_node); - txd = &desc->tx_dma_desc; + if (!list_empty(&atchan->xfers_list)) { + desc = list_first_entry(&atchan->xfers_list, + struct at_xdmac_desc, xfer_node); + txd = &desc->tx_dma_desc; - if (txd->flags & DMA_PREP_INTERRUPT) - dmaengine_desc_get_callback_invoke(txd, NULL); + if (txd->flags & DMA_PREP_INTERRUPT) + dmaengine_desc_get_callback_invoke(txd, NULL); + } } static void at_xdmac_handle_error(struct at_xdmac_chan *atchan) -- 2.7.4