From patchwork Mon May 6 07:28:29 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "\(Exiting\) Baolin Wang" X-Patchwork-Id: 163385 Delivered-To: patch@linaro.org Received: by 2002:a92:3d95:0:0:0:0:0 with SMTP id k21csp1538820ilf; Mon, 6 May 2019 00:28:59 -0700 (PDT) X-Google-Smtp-Source: APXvYqxaYkUwmGcAJraLqg4G+vOsNu/706UAcZzSgFXwGMIX6nC9bIaAYw2Ot3hqIjBushb5V6Ae X-Received: by 2002:a63:2cc9:: with SMTP id s192mr26372809pgs.24.1557127739158; Mon, 06 May 2019 00:28:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557127739; cv=none; d=google.com; s=arc-20160816; b=e5xyK1xubMmEiE9AEsEAralfe+aD6Wu14O3xxd7od75Vbzxki2807eGWgiDJSBJ3A7 nkVX46Bsy4j/xDoFNKOnrBZPWbbDndxfJLorEc5hy+H4klO8ArzfBRQNG//f/OLkRpPY N0gLr3m0sD6VvfsfJ9gLOcS69L+IS4bINUJvS/dqAWCj/1A8ToYuEPbnILcssnArmakv oqWLzhcppKdDe/CrxMLdA5f9hScQ+daoQsLQlIXkbJxAWAT4BLHwbXIWDYDKQPZkT8ZN tDuPCvEDPdzcFQMgsRMaUryI6MBT+6Z+sZfo/s/qjSxc0kt68+szGyRu14mPd/NB8CU/ UdDg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature; bh=XiE8oaht+rMtBmlWqUkyAiRGtKqurxER2iPBNv/AZyQ=; b=1JYE+vvWUo9rKU9LKblFoJMsXufqYpPND9WJXb8Qfx4CyDrzxM5w/X9eN3ZOWmS3E0 i7tX1Zq+xL1V6qbkrbKTOqZQ+vhMjdVAXKQPQ9lIXFZ0k8M67yGn18lHRjlFmvOR17Ng xJmYoqslKJMuKX3naNtKyYJC9r8gIUsUQA3rZnJf63WkaX0oVxP2IZVg1Kt6EwVMufyz gaQVx6y/p0YvHEDgVGxHUfbE6N32mzw469h0Rx2Zj0P1C5zuRwhHxJQLTRFXbRImXwah bSkMtxFfyHY5IKSa0feG65I4lKwvESqomqADUbtbV/TEJBrocdmCEaks88PoSjQbPo1V BsMQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="QM6C/+Cx"; 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=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j5si13850512pfa.63.2019.05.06.00.28.58; Mon, 06 May 2019 00:28:59 -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=@linaro.org header.s=google header.b="QM6C/+Cx"; 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=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726401AbfEFH26 (ORCPT + 30 others); Mon, 6 May 2019 03:28:58 -0400 Received: from mail-pl1-f195.google.com ([209.85.214.195]:39865 "EHLO mail-pl1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726255AbfEFH25 (ORCPT ); Mon, 6 May 2019 03:28:57 -0400 Received: by mail-pl1-f195.google.com with SMTP id e92so5926469plb.6 for ; Mon, 06 May 2019 00:28:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=XiE8oaht+rMtBmlWqUkyAiRGtKqurxER2iPBNv/AZyQ=; b=QM6C/+CxMNKnMh006FzIBzR75xV6ddm6r2gjuSGSnBTOuDfQ0qvMZAiep9jBsBelyX teqGh33rlt74rnloK7VIXqKkie8/XG90UQlY9PEUqS5i6oYPFe1u9h3hNCHny+nnwi01 sqd4g8X8ILX5QLXgsR+H16BiiIRX3xekPo/+zeuPEtWO8CBbs1UhDfu7RtPcFiwhRs+s xl5tF5Punv/vtUbqy/LiKvRqzGspIdKQN8b6+bHCzCbWHN+D+1W4fnyPKnGz1w98WLXf AXbuaK9LrIvC7nQKLYh/0PJxEvCq+BkYvRi/lRTtC5YWoagquPmnnPC/pTgi4/ky7SnV p3cQ== 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:in-reply-to :references:in-reply-to:references; bh=XiE8oaht+rMtBmlWqUkyAiRGtKqurxER2iPBNv/AZyQ=; b=fuHF05LvWzE6kl92x9PB61GsiHksmrZuSilyy5xuQtI3aS5JLWDIa0omM4Gz1HLd+e O26yRJuY1Bes6Wu44YHa+UuFUyJpWq1iSptxth1pPyNlXwsciiZyijAa+bPCrb44Bolu SsqjaU/gD57OjOSbu9ll+msDDbsp3fZuAUbph2+6lH96vR43jxNtyj4bm0tkqUY9LvdF uQ7dFfCWSLk9DCFNF3vGGJvMI+0npQ6VrlQ26YVvPOxTs/6RS8sGKGaBpHynx+Yolhnu 5QEvVGXcx1dFs9V1uf1+06yGv7XMDCyk1jvjAVZIkfQXLxN/VMYRYRQvxTIh1pDNBo+x iR8g== X-Gm-Message-State: APjAAAV/9yISIiZwpGM6TGOkdSYp3airrqkHc8pJYR50DKDF+wRJrhDt Q0NJxXZ5x2CxDW/6aLIcmZewOw== X-Received: by 2002:a17:902:7883:: with SMTP id q3mr30341452pll.60.1557127736687; Mon, 06 May 2019 00:28:56 -0700 (PDT) Received: from baolinwangubtpc.spreadtrum.com ([117.18.48.102]) by smtp.gmail.com with ESMTPSA id w38sm21700894pgk.90.2019.05.06.00.28.53 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 06 May 2019 00:28:56 -0700 (PDT) From: Baolin Wang To: dan.j.williams@intel.com, vkoul@kernel.org Cc: eric.long@unisoc.com, orsonzhai@gmail.com, zhang.lyra@gmail.com, vincent.guittot@linaro.org, baolin.wang@linaro.org, dmaengine@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 2/6] dmaengine: sprd: Add validation of current descriptor in irq handler Date: Mon, 6 May 2019 15:28:29 +0800 Message-Id: <6eee7d5ad68d60ebedf443e24678e5b467fcf0e6.1557127239.git.baolin.wang@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: References: In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When user terminates one DMA channel to free all its descriptors, but at the same time one transaction interrupt was triggered possibly, now we should not handle this interrupt by validating if the 'schan->cur_desc' was set as NULL to avoid crashing the kernel. Signed-off-by: Baolin Wang --- drivers/dma/sprd-dma.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) -- 1.7.9.5 diff --git a/drivers/dma/sprd-dma.c b/drivers/dma/sprd-dma.c index e29342a..431e289 100644 --- a/drivers/dma/sprd-dma.c +++ b/drivers/dma/sprd-dma.c @@ -552,12 +552,17 @@ static irqreturn_t dma_irq_handle(int irq, void *dev_id) schan = &sdev->channels[i]; spin_lock(&schan->vc.lock); + + sdesc = schan->cur_desc; + if (!sdesc) { + spin_unlock(&schan->vc.lock); + return IRQ_HANDLED; + } + int_type = sprd_dma_get_int_type(schan); req_type = sprd_dma_get_req_type(schan); sprd_dma_clear_int(schan); - sdesc = schan->cur_desc; - /* cyclic mode schedule callback */ cyclic = schan->linklist.phy_addr ? true : false; if (cyclic == true) {