From patchwork Mon Apr 15 12:14:56 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: 162190 Delivered-To: patch@linaro.org Received: by 2002:a02:c6d8:0:0:0:0:0 with SMTP id r24csp2850123jan; Mon, 15 Apr 2019 05:15:27 -0700 (PDT) X-Google-Smtp-Source: APXvYqxV1h5gyzHjQGfMmxhbhavRkygvJQvCizvCpDEbcPS8wLJdOMe/hmXQWu7L/AqMTGPEMj1K X-Received: by 2002:a17:902:848d:: with SMTP id c13mr74854914plo.279.1555330527775; Mon, 15 Apr 2019 05:15:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555330527; cv=none; d=google.com; s=arc-20160816; b=d7yPVFWc4DNSkx6mJ2D88m6eBcEV4gjcPZ7hWIZf4iheUO3X/M7j3ziMarbdskMgVs DBDp6PUAlHwZulV+BZLUbDU1tlch1Z1Tsj0MXjiQq+Tjw2G+B54c7r3Tc1zaZLNE0V1n qgjD/BHaISAMOGISWHDDyOAvg8wVQMX7wSMRFZP936f85mChKr9x2INrfxOYoLXqx21o fSEGJGZw3Ul0g9TXOBZ/neZidgRUP7HOdXEOuvLxI5jFvhGO56W7g1MDT0OONfprtNED IE3tTQPak5NWOuBUcxYfYwGkPS4a+mL7yL1gQAEgE2g4HcvWfvbpbNd6i/sS0acLHIbY hglw== 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=mBY8tuCNj9m6hfxTTkY+abZNn//66ZaM/lcTqQjy/wtDNPxEDBstC9aa6HOfElVgEu QEr80OLEp9+joLsSy1XL4UxcOiOBCaMDIbwRoGsQsTuMUIAUQk0Sm5k3AcPIrBAwrqt3 0ioFZhG4FN2H3MnebJQpiF0RozwSHm0bTSUJW4I99pT6dy8/jsPm4pTlfMwgHBncwbFJ hW4hYePNgykRebn8Vy7n+8TTY84/RCzErbFhQYLZ5woMCysKFz17WZkN8f13yriOZppB qmcKKrlV5MWjN73OXIb3IVTDj2BYXYAX91T3wlokpPvbeVzTjzp1qRGTaa2BlHK3SqiJ mGcw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="qLRP/D/h"; 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 11si36430758pla.316.2019.04.15.05.15.27; Mon, 15 Apr 2019 05:15:27 -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="qLRP/D/h"; 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 S1727481AbfDOMPZ (ORCPT + 30 others); Mon, 15 Apr 2019 08:15:25 -0400 Received: from mail-pf1-f194.google.com ([209.85.210.194]:46393 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727335AbfDOMPX (ORCPT ); Mon, 15 Apr 2019 08:15:23 -0400 Received: by mail-pf1-f194.google.com with SMTP id 9so8476310pfj.13 for ; Mon, 15 Apr 2019 05:15:22 -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=qLRP/D/hBzlVyCM9RDEp0f+vh3r0DuWzHyoLapUEEZa49Vw6obIm07znxPAArbNXDx y6lOAS00ZKnidgR6SGOXa/t9lPXGvLz2q1ti+8fdgPMQz+fteVALwWaLWAie/7RPNYgl g6ubl5Vdy9CbG1gzDzKSgBj6TNhnWikVKlpJld4b4VDeqtqp32k3aX7QErvNQEfWWE6e iuq1j14ALAK4WEAVMOv7851BZgFKS2KkKlZ0dujn8lAzV3Twm+7blCirxwnLpnlfdlA+ FBtgU/fzY7iGtpk5ap8KVOqTRhlwfUHIGmPAcKDwT927EK3tNeHmrW5+kIdlQ4osChFs FAxw== 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=Rav1SxelHocZ2LtX/22n5I8tkCw0J/LKeUg1LGkdv1+SHpwHQJkSzDQITcVGAcUxwc FWy3bO98YMemY59LFKUGkxN7M3aWdmZ4ObluWjCRVJmJ3v6H0E7OSy2LYNNDdv6EqOID JmaBTRCVAWz4l1hZ1Xg3u7wYkhQY9LpwFcfx8lI6o9HQFRjYbpPm8dsX5IEbsx0/ncxR DQaKSb9UkNO+k0UWv2vrI99wGMI6v16L/CTCSPMhc+lnZCyd1UgIsf1KniYaNpvh5fym ZTciuZpE694oPN2hq3aSVoxRg4umpNYAnmnrpPtB3vMUHq40rEfwNjPBQaLdsl2TzhwV TAoA== X-Gm-Message-State: APjAAAWmsEUAFSHCieGvgFhwf6b6ygko39owhV1/KWufkT8ycLrKrJ7B bS7vUmEf4L6R/GogsUpcRFoEIg== X-Received: by 2002:a63:185a:: with SMTP id 26mr43154699pgy.337.1555330522160; Mon, 15 Apr 2019 05:15:22 -0700 (PDT) Received: from baolinwangubtpc.spreadtrum.com ([117.18.48.102]) by smtp.gmail.com with ESMTPSA id 6sm64157155pfj.95.2019.04.15.05.15.18 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 15 Apr 2019 05:15:21 -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, broonie@kernel.org, baolin.wang@linaro.org, dmaengine@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/7] dmaengine: sprd: Add validation of current descriptor in irq handler Date: Mon, 15 Apr 2019 20:14:56 +0800 Message-Id: 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) {