Received: by 2002:a25:f815:0:0:0:0:0 with SMTP id u21csp2249289ybd; Mon, 24 Jun 2019 03:17:14 -0700 (PDT) X-Google-Smtp-Source: APXvYqwABJKkXArRYcf7cap0gQjU2YaL7BnhRU9lFI0bp1TPy5ilPBUe23H0W6NDxOcSt17zKOB9 X-Received: by 2002:a63:2109:: with SMTP id h9mr32363002pgh.51.1561371434289; Mon, 24 Jun 2019 03:17:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561371434; cv=none; d=google.com; s=arc-20160816; b=R+Utt5a+wN2hAH1+7PsHReGMmuCjdRQuaq0uaBjjElyOJy/bXmQsItGPAAlmjC/2U/ LzoGhe2eiJ2+ZunEyCt/3UpuJJQRC7UgkjM4XNK+DSKYpEX/ZMJ4hCTjmOxc2aANM/gd lK/nS7yO2iUAInRwA5ivb3CS58BSRyD17ImQbs0CyMemDZ+aFU+5hX3pSjoEUpSk8RGG pZS+rLXL4TFiyl9A9ivShvaxnhwZThD28obaOXXwwgs4B3TNnr0a2DrSaLwcT2vopGwg 2R9FAduUn2d59YqUTaVB+Bbp0Bu4MTXMLHaXeQRUTk5AbAEVycxrd9C+TJTV+FfSw7mV Lf7g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=IPi7ypokvF3RYNOpO1UYvmzQgchlULSz0YVob4NyrkE=; b=ok3rNvmLCIB7oBtoO3ALb0hqfbonZ1/1fnDuixcT25GwRZmWlnTkx4dAiZ9NPwbAvo iKFvuzEObLGFqJ6rrK6iY76r+voCp53ev0AvkEBzOI/pCxv+vXlNdmmWEo8BIMpj+4oh 79Fc8gAvqg/NLYJC7psxb2oCxf35G9kcy6ObiyUzmPHq2Yeef0HyehW+pjLqHxHKgcP3 muPOqSsMEB5KrjORbLlDLbx83PKt4SoRxqeKvmJOJ9FsqQsswAa30rQlL+40CY9fQFf3 X4MUKBSBAWsHwCIUYd90Sny/hNBotLwtv0sTXreDXAFWxGnptHnW7KhCmx4CZ/bl4b62 OLkg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=07hsR1K9; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id cj11si10428096plb.373.2019.06.24.03.16.58; Mon, 24 Jun 2019 03:17:14 -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=@kernel.org header.s=default header.b=07hsR1K9; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727525AbfFXKQA (ORCPT + 99 others); Mon, 24 Jun 2019 06:16:00 -0400 Received: from mail.kernel.org ([198.145.29.99]:53340 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730401AbfFXKP4 (ORCPT ); Mon, 24 Jun 2019 06:15:56 -0400 Received: from localhost (f4.8f.5177.ip4.static.sl-reverse.com [119.81.143.244]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id C1F5F205ED; Mon, 24 Jun 2019 10:15:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1561371355; bh=KDRwmMMXjnhIupyqcWSvt37oEaC6vmIw/bQxsrFBOvI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=07hsR1K9WQcs83sQ+I37VIIzYhTuE5E4msJ4kudybZcQEdvodCysu/kXFRzfbzopn vT4/4HUosrMfSRWxbtFeI5V2qy28GI29i8SAUTwr65n4TFcmFIA/sg+q0Fjh7JOJ4c IizQ9pETGkLz0NqCO3Mx3/V4cZme4hUiQ9wHdak0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Baolin Wang , Vinod Koul , Sasha Levin Subject: [PATCH 5.1 037/121] dmaengine: sprd: Add validation of current descriptor in irq handler Date: Mon, 24 Jun 2019 17:56:09 +0800 Message-Id: <20190624092322.707315593@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190624092320.652599624@linuxfoundation.org> References: <20190624092320.652599624@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [ Upstream commit 58152b0e573e5581c4b9ef7cf06d2e9fafae27d4 ] 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 Signed-off-by: Vinod Koul Signed-off-by: Sasha Levin --- drivers/dma/sprd-dma.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/dma/sprd-dma.c b/drivers/dma/sprd-dma.c index e29342ab85f6..431e289d59a5 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) { -- 2.20.1