From patchwork Mon May 6 07:28:28 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: 163384 Delivered-To: patch@linaro.org Received: by 2002:a92:3d95:0:0:0:0:0 with SMTP id k21csp1538780ilf; Mon, 6 May 2019 00:28:56 -0700 (PDT) X-Google-Smtp-Source: APXvYqwXuf4iMMQzmlF99fm0sTnGdDZOLduJ9FYaVJXGKZ832gwcgewHHnBcbzisSDrVwJ1zZAIP X-Received: by 2002:a17:902:822:: with SMTP id 31mr30095939plk.41.1557127736205; Mon, 06 May 2019 00:28:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557127736; cv=none; d=google.com; s=arc-20160816; b=Vbs4qa03cKKLerhUQUFHOECg09Ny6vG3Mhx1ssHoLexkyaXUdGrFR1MBg3M3lwhMEw I+1Dda/QspqYjOmR1j4OKhxHwc7uivs99FA3Nk7IFv1fvntnnoj8NzpTS45kogilpONQ 05m1Gh+2M5WaICR2DRLM/K2ZnGtfui/29m8UPfi901bgd2SW9Q24fZw4FeT8nrE3BPZk jArmZbFpPpCIqlxzgR6Y/rP/+xzOdSuTK0zSDHA2KxegknpSJJt1BQoKkUwJdz449qhZ X/+0W7GuAdyCPHCoSpHSyJgAH7VG18Yy46gklzv+ObuMijakLI9tLXlosp2M8NL4XSRp 4Vjw== 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=yZiVOrjB2GkVNwkAlHEh8RFkK/dk9IRsTM24Q28H3wk=; b=fKxuH1CVjBFI/NPtCwOKSjuLfbP/v4768YLhEx8HQFKvTM81CMZTS+LjW6g/wHoCME 4bSanNz+yhrXvQVSbcrePN20qeC1DGugnyEDkoMvVbFnk9C9sNqO15luoeNcceEIzHuA h1muMm6EVuhhltsmva1oryu6I2oCyLJEj+c/Vf0VtwDOUSYOD3x190zXr1LkbYohsi9P svuE+9AnAANZdaAjSSs2KKGjir29jQgbtqirh/cLVrL3AkYvoURFoLbDihLvANm+EuY7 oj6IyNaFVBqlaAPfopjsrDBIYzK2zjUHU1zly/MQv1868sheidsMNd5q11ILWf4xVF9j GpEw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=BIbUM15m; 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.55; Mon, 06 May 2019 00:28:56 -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=BIbUM15m; 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 S1726327AbfEFH2y (ORCPT + 30 others); Mon, 6 May 2019 03:28:54 -0400 Received: from mail-pg1-f196.google.com ([209.85.215.196]:40431 "EHLO mail-pg1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726255AbfEFH2x (ORCPT ); Mon, 6 May 2019 03:28:53 -0400 Received: by mail-pg1-f196.google.com with SMTP id d31so6029222pgl.7 for ; Mon, 06 May 2019 00:28:53 -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=yZiVOrjB2GkVNwkAlHEh8RFkK/dk9IRsTM24Q28H3wk=; b=BIbUM15mdf5AnhdYErzvP660w8KBiAQdvle7iP059JvrT4k+uzyqvT//ZxuanToIjD 1Kb9X+z0JegAGTabVvBbhp740j9+Izw32tIaWryq1OWoDktcb7SFTJXvkSBBS7XIy5BS w/TZVda78BdDeIrOpWMJpPJlAeW2kdDO0hhjnbpr4wjtjYlJEebf+aTL7fDHI9F84eWI b+hqqNP3fOdVK/ZGwIf6/bOjKzgQR1ABGO4qaoTi/1KjD7SJ2JO9i/V7XHK+JE2/5OOZ sqZ+h030Cbc/0UU7plh6j9v/Vf5ktuW4KK9cnoS69oR0f4KFJGhBgsbgaYtwMB8gc300 CBPQ== 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=yZiVOrjB2GkVNwkAlHEh8RFkK/dk9IRsTM24Q28H3wk=; b=O398iFE2ZC5p7Jwjwr/JHvtpt2axRFtsCaLLYA6mWy6ngoCO6dzx2T/oPKQe43OBr9 87Pe4FwEwOuriJcAwJcRYXvsvay2cReAD/yd8hTPL4scFtYWlbujRBu3nx3Z1KKH82RY Rc2Tqopm0DgiF1pmJsUtbPgh+2oQvO4kYtv+SZ5Kbj+3iCDZmRxP8i62rSVIid9U4g9H ORYU3S+7xGwlINJi2tLfvVtR4+2Y5+7hedUPMH2Q8e5iIVx5oCxIeEJxc+aQtiJNNs+V mQX+n/ADp9ueJV/SZ2ySiHOcHxpJAvpyduWNaBkRHVzFmesfQ+gcnUZtIeU+zt8uzlSQ A3fA== X-Gm-Message-State: APjAAAUW0nK7RGmfozyAfL9yWxR2RzZtzw12r5jfjIBn2YIrb+sCgArD Pbg1I+FwZawZd+Aad2g2bdPbJg== X-Received: by 2002:a63:5c24:: with SMTP id q36mr30268665pgb.314.1557127732915; Mon, 06 May 2019 00:28:52 -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.49 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 06 May 2019 00:28:52 -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 1/6] dmaengine: sprd: Fix the possible crash when getting descriptor status Date: Mon, 6 May 2019 15:28:28 +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 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 descriptor status. In this case, since the descriptor has been submitted to process, but it is not completed now, which means the descriptor is listed into the 'vc->desc_submitted' list now. So we can not get current processing descriptor by vchan_find_desc(), but the pointer 'schan->cur_desc' will point to the current processing descriptor, then we can use 'schan->cur_desc' to get current processing descriptor's 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);