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: 10900663 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4DF2C139A for ; Mon, 15 Apr 2019 12:15:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 38627287EF for ; Mon, 15 Apr 2019 12:15:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2CB3128807; Mon, 15 Apr 2019 12:15:58 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CFD30287EF for ; Mon, 15 Apr 2019 12:15:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727244AbfDOMP5 (ORCPT ); Mon, 15 Apr 2019 08:15:57 -0400 Received: from mail-pf1-f193.google.com ([209.85.210.193]:34852 "EHLO mail-pf1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727177AbfDOMPT (ORCPT ); Mon, 15 Apr 2019 08:15:19 -0400 Received: by mail-pf1-f193.google.com with SMTP id t21so8512482pfh.2 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=YTTkS8tIj4yWr1SexUUBEpa6MpDZrZkymo+mhdIJrW53ymV1SF5/b4caF5KJuJZ3OE iQ5Kpdaqgh7KkJxlkgTyvnLyhxm8bfzX/dy4mtoS3kmXkYkE3zv/mq3uvNN7WRKhe9BM 9ciF9pCkcuU7TjrQz5w7o978NwnYMiOP9bErzKQ4ihyitBfYbDF/37vR7RSH9qccBLE0 RMkYoLjWVgmQ2uDyKeNnuSawUGTqlo0K85bbrISYW7GBtVaGNeWVClIC6t7hdzgh3sk2 jPtW2ocDomL8HA8I8nm549FyHqeZwNb8YGGtNXuAnzWvmQ1GQdxFE9HGSuBba+rEWvw4 y7Pg== X-Gm-Message-State: APjAAAW62Q3S8B1reDQ193OSanvpuh8wTA9M9nXRDgwWp7cM7RL2iC7s QgmYVH/WXGpYRMvxLyKTxqTjvQ== X-Google-Smtp-Source: APXvYqzFwA1PM9j5ZwIwdADWuSPlcmW3p3seKOvWmE7l0Qs8TQWml2IfQNh29iOponW4uMd7MtMLlg== 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: dmaengine-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: dmaengine@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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(-) 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);