Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp853232pxk; Thu, 17 Sep 2020 19:07:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJws3bnyA7PsnSwgah8xEh2UARJoltMfeXT5e2hz7/0oND9JXSmkQWvLQJyixMoeBi4jNrI6 X-Received: by 2002:a17:906:4b18:: with SMTP id y24mr33265982eju.471.1600394879298; Thu, 17 Sep 2020 19:07:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600394879; cv=none; d=google.com; s=arc-20160816; b=h4OAfI2XejxXFjS8eSLYTLHa3b9Cd9ZPrKWULWkDWWDB0I/bCIjXVgD1azzcKnD8g1 D0EUkRbLyX23bFSg5VwkqnLvCK4D/DzKysv26HyGiz5EG7bEkCwotQJIdLiJi71Dkzrn 9flByKp47Ole5AQ0iQ3TquAndMlKa/Vhx76zWLp3bhWyz0uV4VMl7EMyFr8xa1Az5N5e B3Muxwd5p29h6Q47uRzyNs4qHPMD4rUA9RZLKNzVMyun9g7hLZ+e/Bxbt4HkA+HPWfk8 A0BFWqUCxqhgvQWoDXXn0KCgng+udTr6+jp8WxyVhLVbbHR3ghhAsHgkR8NVXf/Jbjv4 4oog== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=xaKuy5eiTr1DR4k24xkcc7G9LOn1gaDmCx+6oRtngQI=; b=Jx/WRy3vng6u2mDayo9q+Fx9YT9GAdeoCBvyQfUVC5uLkooFd3VxFw55MKPoJVBU6h H+SeROrCI3QRCq4xHeQnWJwODKh3f1JXNDshO2raJmwVJ/B/6/A74jRvRwh17Z/fi6AZ d1MvvGp7rAdcFn32FdHJqXjLHqlMR/uVGPdloBpOWcRpY2YR8x7c/6cmI5xtMQjHLCYy 4J/3xhy5OlL8pXzBeCa8aHUAXlChy17GdJoyg0vIXRFAJOAVUKWePLUpNZ6wbKH73nCw p3eW4eAScyGg1QzaznvzQbwSP7PqsgwLOL3If7uWnqlwVW5QwCnga3d0ZrRiUrrSzKPO y85w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=AEqVKyOK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i24si1185240edb.493.2020.09.17.19.07.35; Thu, 17 Sep 2020 19:07:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=AEqVKyOK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727254AbgIRCEL (ORCPT + 99 others); Thu, 17 Sep 2020 22:04:11 -0400 Received: from mail.kernel.org ([198.145.29.99]:50982 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727218AbgIRCED (ORCPT ); Thu, 17 Sep 2020 22:04:03 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 4D43A2311D; Fri, 18 Sep 2020 02:04:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600394643; bh=SvIJh07UqMEX773ha9mfl9vjNO/Yk8dtySZJaD5i3jo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AEqVKyOKrSD+7zCAOgxBqPjsaCbCJqAJVbn3aOVxcVhqIqDLEJ63Nc89fxz67140U 3O3kglw2btzzbJ7+Hp/bV4ih69OKSq2oDRPDw249b+QAS0bmF8MVHC5Idw096qm+Vv cGZOatXPcek7rMLxVVqemS4a0CFVkfjqD02av0Kc= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Dmitry Osipenko , Jon Hunter , Vinod Koul , Sasha Levin , dmaengine@vger.kernel.org, linux-tegra@vger.kernel.org Subject: [PATCH AUTOSEL 5.4 141/330] dmaengine: tegra-apb: Prevent race conditions on channel's freeing Date: Thu, 17 Sep 2020 21:58:01 -0400 Message-Id: <20200918020110.2063155-141-sashal@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200918020110.2063155-1-sashal@kernel.org> References: <20200918020110.2063155-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Dmitry Osipenko [ Upstream commit 8e84172e372bdca20c305d92d51d33640d2da431 ] It's incorrect to check the channel's "busy" state without taking a lock. That shouldn't cause any real troubles, nevertheless it's always better not to have any race conditions in the code. Signed-off-by: Dmitry Osipenko Acked-by: Jon Hunter Link: https://lore.kernel.org/r/20200209163356.6439-5-digetx@gmail.com Signed-off-by: Vinod Koul Signed-off-by: Sasha Levin --- drivers/dma/tegra20-apb-dma.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/dma/tegra20-apb-dma.c b/drivers/dma/tegra20-apb-dma.c index 4a750e29bfb53..3fe27dbde5b2b 100644 --- a/drivers/dma/tegra20-apb-dma.c +++ b/drivers/dma/tegra20-apb-dma.c @@ -1287,8 +1287,7 @@ static void tegra_dma_free_chan_resources(struct dma_chan *dc) dev_dbg(tdc2dev(tdc), "Freeing channel %d\n", tdc->id); - if (tdc->busy) - tegra_dma_terminate_all(dc); + tegra_dma_terminate_all(dc); spin_lock_irqsave(&tdc->lock, flags); list_splice_init(&tdc->pending_sg_req, &sg_req_list); -- 2.25.1