From patchwork Tue Sep 29 10:57:46 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 263103 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=-13.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham 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 309F3C4727F for ; Tue, 29 Sep 2020 12:08:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CF7C120773 for ; Tue, 29 Sep 2020 12:08:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1601381299; bh=SvIJh07UqMEX773ha9mfl9vjNO/Yk8dtySZJaD5i3jo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=sWYGKP7cxWqUl/ZokyG8DS66ujxucZWWStoUwhy2lWQlrf5asQUNTWRuK5MRn/ezh 3F8IDSHhn20Av314iG6E7LKXP78E7NBK9YM07RShVtLoO0CLcj3GzWMqVW8IF5qxUv 90snlki9WDBhJqaWiBucXJf0f6rDThhVJ1xYJwKQ= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731321AbgI2MIT (ORCPT ); Tue, 29 Sep 2020 08:08:19 -0400 Received: from mail.kernel.org ([198.145.29.99]:55996 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730231AbgI2Lhg (ORCPT ); Tue, 29 Sep 2020 07:37:36 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (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 3B11023B55; Tue, 29 Sep 2020 11:36:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1601379374; bh=SvIJh07UqMEX773ha9mfl9vjNO/Yk8dtySZJaD5i3jo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=1HDimXehda9rwCuG/N9KmodIMxbQeokYGk8HdmnSzHrZUhJ5pcbREz2vZR+5lDJ6T B/6efWVprhW4KyFQUeFBi8dc/tQVBYeD20hG+0yHyBVYMCr2I2Razd6Ab4cbB/B++5 WM7vUCoX1pOELJ2n8ZzdyialEWxOAMlXqnMFk9Rk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dmitry Osipenko , Jon Hunter , Vinod Koul , Sasha Levin Subject: [PATCH 5.4 135/388] dmaengine: tegra-apb: Prevent race conditions on channels freeing Date: Tue, 29 Sep 2020 12:57:46 +0200 Message-Id: <20200929110017.009426557@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200929110010.467764689@linuxfoundation.org> References: <20200929110010.467764689@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: stable@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);