Received: by 2002:a05:6358:5282:b0:b5:90e7:25cb with SMTP id g2csp436840rwa; Sat, 20 Aug 2022 06:45:12 -0700 (PDT) X-Google-Smtp-Source: AA6agR5Bb/FVWi3qg+uaBAS9fWm1Ps1ujCTcYcpDGC9soBBNyBRH5+/fUWy+DPvqqvlzDyju47Cd X-Received: by 2002:a17:902:6b47:b0:172:9b8b:a3fe with SMTP id g7-20020a1709026b4700b001729b8ba3femr11861553plt.13.1661003112502; Sat, 20 Aug 2022 06:45:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661003112; cv=none; d=google.com; s=arc-20160816; b=NeheM7tBGIvofpDHZEjA3CVg4Kiy9w/hth7STRvEnIkWD4jTdU1nCkQKoDBsaDFBA0 rCHPgMti5tAWyAJ1oO04QA62W73ai97UE35xHfOop4Hyp52hQEhlyJ8lzWS9WmNufVJ7 SAmO3HcvwlkTcbbGwri5iG7b5vJjqAff7SSv48mvRAapciceUq5TKF/m12CRshc5bAo9 1n8ZRfU73cDySWnbZrwzJV3F25mDKiWS2EYKOso9bWEhLbelzc96Lr7+Uy+7MqzDwsfR 3TJsc4h8wBjBYpy0ymtq3TTZ6aCPMmvUcXzWuDogEscurVFPzIXcRSTFnabeTCsWzjbE 6yfg== 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=osAoGTFaifwm279K8siOwCYuh5U3dRqHf6oxnMCu/uA=; b=Aq6ADQL4fI228pNxulev/HpDA+60hY9rQWYld1mlHvpOlRzWPC6YjQ3/ved15tWkEg 50OV42TuUEwEhv+uAMqls8J8FXGqVNT8X1KMcNTPn1sUt0ewQ1dFsKQD6/H9oAysS7W8 8RXRrqtXiz2JcM6Z9UlfcBz59TF1jl019Tj26y99pjOj6AcS1lWL+lYbhKAkfgFs+n5i VsMv16qo2LO+ALAPobOvhhMrEVDcHLgjT+PhdL+E5Zf1mGFpBEzp2GS1EK6MBcR+giFC inDM7bHP5l/pjIp6jaxY9LY7PfeTSBD3ta32gIFYCLvcbXDAJC50TRkImLYKfM0QHNDM dtug== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microchip.com header.s=mchp header.b="t0wg/mFo"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=microchip.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i13-20020a63130d000000b003fea0415b5asi6858722pgl.834.2022.08.20.06.45.01; Sat, 20 Aug 2022 06:45:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@microchip.com header.s=mchp header.b="t0wg/mFo"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=microchip.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347044AbiHTM6w (ORCPT + 99 others); Sat, 20 Aug 2022 08:58:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33102 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346775AbiHTM6b (ORCPT ); Sat, 20 Aug 2022 08:58:31 -0400 Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.154.123]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C05C486C02; Sat, 20 Aug 2022 05:58:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1661000285; x=1692536285; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=HC98+2Q3J7wqLV6loiePisXOhcp5INxBFqCWpy13QbI=; b=t0wg/mFof51+s38D7c2SoI5bU3q5pWDd5ATcNe3S9vsgV99TI+vxn8nS jLSUt0HTW+dqJj49pcJkj2+Q4EdHXcYZT1RFA3CBWsT0ZqGYfU/LbT+CG c3Sl/4uuNEBlKYqWjI4xfg4lVjVx09ZAqtZXxFcV7JECaBHu3tEtaySLe d3JLDsa8Z094depIph8O8ShJJcRHzyTo9qfWRlTeqQ8BruU3nORDW7a6x XFcNN0ddbwGmB538FNAdMcRgN1gpzq0ICDqX7+yvgPca+/Ag7u9HOH+kQ 1iqlFMuCSGzU4MHUIUj8otYyXF7dRgtP1TV5szOmk8iirRpjr8wTD3KX0 Q==; X-IronPort-AV: E=Sophos;i="5.93,251,1654585200"; d="scan'208";a="109911419" Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa6.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 20 Aug 2022 05:58:05 -0700 Received: from chn-vm-ex02.mchp-main.com (10.10.87.72) by chn-vm-ex02.mchp-main.com (10.10.87.72) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.12; Sat, 20 Aug 2022 05:58:04 -0700 Received: from ROB-ULT-M18064N.mchp-main.com (10.10.115.15) by chn-vm-ex02.mchp-main.com (10.10.85.144) with Microsoft SMTP Server id 15.1.2507.12 via Frontend Transport; Sat, 20 Aug 2022 05:58:01 -0700 From: Tudor Ambarus To: , , , CC: , , , , , , , , , , Subject: [PATCH 12/33] dmaengine: at_hdmac: Protect atchan->status with the channel lock Date: Sat, 20 Aug 2022 15:56:56 +0300 Message-ID: <20220820125717.588722-13-tudor.ambarus@microchip.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220820125717.588722-1-tudor.ambarus@microchip.com> References: <20220820125717.588722-1-tudor.ambarus@microchip.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_PASS,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Now that the complete callback call was removed from device_terminate_all(), we can protect the atchan->status with the channel lock. The atomic bitops on atchan->status do not substitute proper locking on the status, as one could still modify the status after the lock was dropped in atc_terminate_all() but before the atomic bitops were executed. Fixes: 078a6506141a ("dmaengine: at_hdmac: Fix deadlocks") Reported-by: Peter Rosin Signed-off-by: Tudor Ambarus Cc: stable@vger.kernel.org Link: https://lore.kernel.org/lkml/13c6c9a2-6db5-c3bf-349b-4c127ad3496a@axentia.se/ --- drivers/dma/at_hdmac.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/dma/at_hdmac.c b/drivers/dma/at_hdmac.c index b3895e5d2ae9..aeb241832c52 100644 --- a/drivers/dma/at_hdmac.c +++ b/drivers/dma/at_hdmac.c @@ -1902,12 +1902,12 @@ static int atc_terminate_all(struct dma_chan *chan) list_splice_tail_init(&atchan->queue, &atchan->free_list); list_splice_tail_init(&atchan->active_list, &atchan->free_list); - spin_unlock_irqrestore(&atchan->lock, flags); - clear_bit(ATC_IS_PAUSED, &atchan->status); /* if channel dedicated to cyclic operations, free it */ clear_bit(ATC_IS_CYCLIC, &atchan->status); + spin_unlock_irqrestore(&atchan->lock, flags); + return 0; } -- 2.25.1