From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9F068C43463 for ; Fri, 18 Sep 2020 02:46:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1463D235F8 for ; Fri, 18 Sep 2020 02:46:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600397213; bh=oeQh2faaJrkwcSxYRQm7EI3c0i3vlI+q5lipaebE1J4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=2OfMbahbQHRSioJeon6XWzWbbzV/9CFT2nj1OyX4IshKdKB86g+/vOno6A649GK6Z DgWSjEi8Yi9bV4KK9WV+BNs5yQ2Lpw5jn5P7D3FBjAh5hCS0d0a+NE1Po2Qe/RnH7N 2jWrviDlPb+8k+MRrMFRHU8mkqi15VAVp7OFZl6M= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728820AbgIRCqf (ORCPT ); Thu, 17 Sep 2020 22:46:35 -0400 Received: from mail.kernel.org ([198.145.29.99]:33866 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726667AbgIRCJv (ORCPT ); Thu, 17 Sep 2020 22:09:51 -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 089C823A03; Fri, 18 Sep 2020 02:09:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600394990; bh=oeQh2faaJrkwcSxYRQm7EI3c0i3vlI+q5lipaebE1J4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Xp9MFmQqlEli2ZQQkg/Fog7tgj8K30nae/B6gpGiZlgEDKtJvG92xWFpFmLwQyq/+ cR2c6kf7lXPRFK7tpSnYO3O3nulVr788H3JHolCt68A5ipDbKp3jpLVXkvYjR4He6b 3mEYLZiRDMkF3cwTqGh+PtFIapP1Z0GjxYM4zGLQ= 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 4.19 089/206] dmaengine: tegra-apb: Prevent race conditions on channel's freeing Date: Thu, 17 Sep 2020 22:06:05 -0400 Message-Id: <20200918020802.2065198-89-sashal@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200918020802.2065198-1-sashal@kernel.org> References: <20200918020802.2065198-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: dmaengine@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 15481aeaeecd1..5ccd24a46e381 100644 --- a/drivers/dma/tegra20-apb-dma.c +++ b/drivers/dma/tegra20-apb-dma.c @@ -1225,8 +1225,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