From patchwork Mon Apr 15 12:14:55 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: 162188 Delivered-To: patch@linaro.org Received: by 2002:a02:c6d8:0:0:0:0:0 with SMTP id r24csp2850020jan; Mon, 15 Apr 2019 05:15:22 -0700 (PDT) X-Google-Smtp-Source: APXvYqwaIngvpKUX9QC1ut1uKc4ZpnQXhstSm3yi0F+VZSHhtdgdT1kG2DzbimNeTC+YfuMyvCNO X-Received: by 2002:a63:5057:: with SMTP id q23mr70591599pgl.30.1555330522886; Mon, 15 Apr 2019 05:15:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555330522; cv=none; d=google.com; s=arc-20160816; b=MCU5myl7JQItSZ67m34N239hZK5tp25AozbVjR/KtF0btNphu71aU/a2cW+z4SZpJX m1v63BTJonhj7fvPqAJ0FY5KbeY+l57DrycC8le4nbwRRajyAhh2LZAdhH9HS3Jlw/sf 7A8pZDEpDFRPmZfurbda3xKM3laS4inCcmYQUSQV6K2DMSW9s5kLF20nGcDlFbFk/vLZ ShJdTp71F11ieZ6JQFQSh57SkpOINtFZkIEdSVNJQ1flKB7RdbSheyifmN/c/vMKrL/q K2F21Q+Wp8UjbYs4pLk/QBXmtJc0+JruLfMdDflOoe2DmQvZoc1rDzqrYHs8HKPLU1Xl /8cA== 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=CAUNijlh9/PyuN9Nu9xMccDkwi74nLVT9vlXbtkz1ds=; b=KjucMcwSNCb3EqjpQ1jm2K3jKc7cBnFjKUifwRjdTQyhfOuu8x9EZNRfO146kmfbLX 6QpdkctuUz9CqSQnv1LWVtvp5sd8vcXR0Rcl8CGwpbkjG3BvfP90LxUknzNJ+keD8Zd9 PB6vMRjxGdaFhMUljVqhJPixvu6j4X2QlXlUwsa1UhegsMEcyjS7UXLXET32HsMQemNA Rxg8CEhQ4JequZ7tDDNyury3SxJpYZs8Ndw1R83Mpyw/2hV5NDPabJQCrL8ZFZi0Hd5g 12t23J37gN7od+rwq4Pmz390DFRq+u4L7cH1Bx6EDwJbm2J4RJebpQAVsfycwvaDMA6v aMmQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ucpboVWl; 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.22; Mon, 15 Apr 2019 05:15:22 -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=ucpboVWl; 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 S1727466AbfDOMPV (ORCPT + 30 others); Mon, 15 Apr 2019 08:15:21 -0400 Received: from mail-pg1-f196.google.com ([209.85.215.196]:36324 "EHLO mail-pg1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727433AbfDOMPS (ORCPT ); Mon, 15 Apr 2019 08:15:18 -0400 Received: by mail-pg1-f196.google.com with SMTP id 85so8502231pgc.3 for ; Mon, 15 Apr 2019 05:15:18 -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=CAUNijlh9/PyuN9Nu9xMccDkwi74nLVT9vlXbtkz1ds=; b=ucpboVWlQ5/w5Wu9P8+gVZtpfga1IRqvUoAo5DPUJU0Pxdb6xA3tpyd1e57aAy0pgb ieOVfBtAJXpRZlmX+n4tMGCGGW29Ce6U+Q6HYFKnLDDgGfjQRvXQU+sW3fvbiDsXBT5q xoHIE5eZorhruD6XJdKUujPzV+O+DgFbHynEfd/Zn795a42mbE+slNNCFEcGW3VOb7Hg WSm2R4TRtGlQQY0mBjPS4YHtzOABnCp0hiYddfZLU/keK/qtdoA74w0aJDpksXTM5gNY mE8OQW8PaFIsb4FMsKRjHLw1c1kymt/Cs2IWeMgDqIoJlEDmlNXpkEGl0QBxGHpw2OdI IHPg== 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=CAUNijlh9/PyuN9Nu9xMccDkwi74nLVT9vlXbtkz1ds=; b=ec8UHP8MBN0/ZXwtrEw2NWDnGJhkVA1xQoTJJoADmgVjoM3OLNpsrcaRsdgFRbDyr+ 9YUv4eDG9P/aHiQvDCHi8MCNWQsJz6ogGMY2/UOteSxJ+nGhrQ3+HJVzpPoo1ed5/Mp/ q5ieMNdl57PLVFrtgzBdehpAnuImAnUx4/yVqthm0PuWmm86XvrhznuVEyAjzppOqFJK Lry1m7tpiwqiZssjJq4l1HPXNnJs+ku/lNnup5MM5qlMRJvC0z1Af/ZvZ5DnSh5pd8bf 21uC7VrEZ/GP/bl4tWx1+iqLKGkl0Uge35oQEMjvbqmCtRoPhiwejCsGSMBecjhqL0s5 Cp0g== X-Gm-Message-State: APjAAAX4A4cVF2XyZiIkvdJzn3pyM8eQqH5iluJmkXfF86NRgWUzGGD6 1z+pA2lEyLZ6cXPoT1uVm+2rww== X-Received: by 2002:a63:b64:: with SMTP id a36mr70563796pgl.58.1555330518223; Mon, 15 Apr 2019 05:15:18 -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.12 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 15 Apr 2019 05:15:16 -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 1/7] dmaengine: sprd: Fix the possible crash when getting engine status Date: Mon, 15 Apr 2019 20:14:55 +0800 Message-Id: <2eecd528e85377f03e6fbc5e7d6544b9c9f59cb1.1555330115.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 We will get a NULL virtual descriptor by vchan_find_desc() when the descriptor has been submitted, that will crash the kernel when getting the engine status. In this case, since the descriptor has been submitted, which means the pointer 'schan->cur_desc' will point to the current descriptor, then we can use 'schan->cur_desc' to get the engine status to avoid this issue. Signed-off-by: Baolin Wang --- drivers/dma/sprd-dma.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 1.7.9.5 diff --git a/drivers/dma/sprd-dma.c b/drivers/dma/sprd-dma.c index 48431e2..e29342a 100644 --- a/drivers/dma/sprd-dma.c +++ b/drivers/dma/sprd-dma.c @@ -625,7 +625,7 @@ static enum dma_status sprd_dma_tx_status(struct dma_chan *chan, else pos = 0; } else if (schan->cur_desc && schan->cur_desc->vd.tx.cookie == cookie) { - struct sprd_dma_desc *sdesc = to_sprd_dma_desc(vd); + struct sprd_dma_desc *sdesc = schan->cur_desc; if (sdesc->dir == DMA_DEV_TO_MEM) pos = sprd_dma_get_dst_addr(schan);