Received: by 2002:a25:f815:0:0:0:0:0 with SMTP id u21csp2248553ybd; Mon, 24 Jun 2019 03:16:26 -0700 (PDT) X-Google-Smtp-Source: APXvYqy17lBB1HuQlJp5N8ffUWmeZJP0rO1FUbqzzJ+q7/S+3X4i/yxrNrU4S4okZXo7sAYX5Knv X-Received: by 2002:a63:6d4a:: with SMTP id i71mr21200309pgc.106.1561371385983; Mon, 24 Jun 2019 03:16:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561371385; cv=none; d=google.com; s=arc-20160816; b=XcT8VyrHpE5JjpZwdrQ2xC718mz+/SQ0f20j6tN04eREv8gTiC+Ou37USYeeAljpv9 wWIKa6Gv25+LxITvX88cYBF4PzzK/xTTw3zxWn40iAZkAHqGz4ZVN9RfVfSoLW3l6DBb dqILIxuYsE+w4e3iB6B3smljKi1iR00nmgck7F9GUyRWd1Q9k5qbN2tkQkVxxiu5VZWQ Eol0fYo5YTgWBbdzecUnYJS7GlJ/SSVVaJHxNO7QhiUa21C2GrfJE74rdis32i3rc/LS 9gL43A+AAuZI4XgUjxVNpsKgO1MI00E4Q6gJTO9gfSvSKWpdyQxJ26j/2Se9JAWCwkZ9 PHtw== 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=Ay0UIKhX/Wg9kRxyMtm+v5hmdC+4pRO6h8MPhbUriwM=; b=SqJauQwL1QGgnqc2Q4fNWTYD5SBIuvqFI7RCz+UrkE5n+AdkMBSXs7kYGolaZKlf+v jLxoaFUgubFa+NlPkHrnfTTXY3OhdZSq8jXCE1GpIZsw+LxZA2UDddZ///JFxnyw8ltI 2Uw4+YJo4gRqzv2muJJk4Oixn6UnbDDNMj6nWVsQVN1xeqtx6E4u4m9pADoOHLmOH+hG QqagF/zOpLqhslHZqs2VzQwOK+Cu9bjHRITftD7P/LS4knC/IDAaabDAYRpZ344BWYT2 zbcdSQslGvQ05AzKEBFI1B+mp8J9jPC0rW3mYTRg3FH0hhD8LRu0UwItYILQC3camnfv s6+A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=jCA7SiNP; 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 v31si10865469pjb.22.2019.06.24.03.16.10; Mon, 24 Jun 2019 03:16:25 -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=jCA7SiNP; 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 S1730409AbfFXKP4 (ORCPT + 99 others); Mon, 24 Jun 2019 06:15:56 -0400 Received: from mail.kernel.org ([198.145.29.99]:53298 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730025AbfFXKPw (ORCPT ); Mon, 24 Jun 2019 06:15:52 -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 1172B20645; Mon, 24 Jun 2019 10:15:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1561371352; bh=iX2Cvxv91ZoHMIbqMcsmuPSIR3ZlwV71LpYzXjuL+B0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jCA7SiNPp/vsvvBstvbj3qe4Fkfk89um9DEKxedDdTfTAMf31SGNnOZg/wB69s7FS pfP+CrHW5/lpH25bsduFNU99HasiKU0he7Um2YRRGqZ66J80PF9iKqtdjbvHhT3AUo ailpaR7q4x6bkO2zqFhxxJ2JsplSb2sa1J0+Zkos= 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 036/121] dmaengine: sprd: Fix the possible crash when getting descriptor status Date: Mon, 24 Jun 2019 17:56:08 +0800 Message-Id: <20190624092322.661887903@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 16d0f85e45b99411ac10cb12cdd9279204a72381 ] 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 Signed-off-by: Vinod Koul Signed-off-by: Sasha Levin --- 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 48431e2da987..e29342ab85f6 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); -- 2.20.1