From patchwork Tue Oct 25 09:02:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tudor Ambarus X-Patchwork-Id: 10605 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp891694wru; Tue, 25 Oct 2022 02:07:29 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5WFlFkKl8Smb7UdAJJvtOOH+cFqy4KoBG4itbqZMqOU8CJsufr7+mdsj2+hOEUEFdcZT+t X-Received: by 2002:a17:907:7290:b0:78d:ec20:fe4d with SMTP id dt16-20020a170907729000b0078dec20fe4dmr31912945ejc.528.1666688849382; Tue, 25 Oct 2022 02:07:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666688849; cv=none; d=google.com; s=arc-20160816; b=SiujMkgj4VVfAA2xVfBc66r7nEs4jCjCG1JRSC1hGU1ZpiDTApsPCcaBu+MuG2rkQe gmnfyizvQHi1vzZ4cqdYtl/+SDjh5OsDRmWZrgZ30M4QC2FomlOqNCopQAS/IA5CmGv1 02XFRtig66f5rVwWGwoI8bqb1lUiPjqP/puPyKDTwGr5bwzdXFvdyUEjg0eWDIsmKjka 7yfsC/dM7AK2+EFz2Z3PUSe8kdpIGiQ/2sLNdCRqA8+NQQKWajnFcs6oYsuRsRJVIjkn aTfyNKimi1kMdmsFywbSgnaPEGg/7umwCq83mdrmSOjZ2qOc/4TgsH9UX3ZAd4md41dl TKjA== 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=LuK8f2dLzhHgQCGKOD7HrrACPe/oob2RDZIoxnFbOGU=; b=a1aUFRxiiWyjwpt81Ns1+pjf5/ZV7DiIMM6JgTF6Nel/qwqFOcxC22/uY+yAJ708VH 4QZUVFKIBfbW1GvOyAXgtSkLNUjFDLx9pIsRMHKuDtqsEnKq4A1/re7bO34fB1O00tqa CcbhsskML9q6Xxbk4FhTb+PlgmZjTQ2Z930oBzfeU7LSKQhrR9RprUoo+c2TK1Or+qp/ ILv7M+uOy6voRX9yc1i6RpkAS4bM/hmL3Pps7/P4ypZBUZuTX984k7F4z1u00ZcB/6NH KjeD+oqsTuLj8lnb+7RlN2/whre/M5AK4Fi/s0OXY2lh+vJGPSbPgCyRqqlhzty1Jnqp Uo0g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microchip.com header.s=mchp header.b=fbI44eC+; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id qa8-20020a170907868800b0078d8db64fffsi2605178ejc.20.2022.10.25.02.07.04; Tue, 25 Oct 2022 02:07:29 -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=fbI44eC+; 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 S229936AbiJYJEK (ORCPT + 99 others); Tue, 25 Oct 2022 05:04:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56510 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231664AbiJYJDv (ORCPT ); Tue, 25 Oct 2022 05:03:51 -0400 Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.154.123]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 779C915A8F6; Tue, 25 Oct 2022 02:03:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1666688613; x=1698224613; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=d1t0ow6YIdu9Rv1rkKmxVrPNsexG/0cDcLPtXg9M8P0=; b=fbI44eC+HEcCvmNe+U6FGf+28WIeYrckJcNXrP7eMaC+7/tdGbnC4Cs/ 4wlo9zcE8+8czfWX1ErMJ81Uzo0EbXCAo2Ng9alGy0tXCcfJdsAea+sFM m/Hf47iVdXrgKjREYInOOTd3wvYqQfesjxaPhZnzyAah6G4Rtp+0ozQ/x GDyGoab82KIl4ORr1HS1XgmkKVnsq43KYpz3uTzQ5c5oGEF2bmg4epOFh WPYaREwZOLEThOK5SVvb7iGf6a1yNKTigT3KkT2aAAAiUwIA0r7Dqse2j venIANILdUZILoe+NfqJv7b/8FBPj6+zW4RyNPPdB6OkpQ6By1tZ2XyfH g==; X-IronPort-AV: E=Sophos;i="5.95,211,1661842800"; d="scan'208";a="120221243" Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa6.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 25 Oct 2022 02:03:32 -0700 Received: from chn-vm-ex03.mchp-main.com (10.10.85.151) by chn-vm-ex04.mchp-main.com (10.10.85.152) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.12; Tue, 25 Oct 2022 02:03:30 -0700 Received: from ROB-ULT-M18064N.mchp-main.com (10.10.115.15) by chn-vm-ex03.mchp-main.com (10.10.85.151) with Microsoft SMTP Server id 15.1.2507.12 via Frontend Transport; Tue, 25 Oct 2022 02:03:28 -0700 From: Tudor Ambarus To: , , CC: , , , , , , , "Tudor Ambarus" , Subject: [PATCH v2 06/32] dmaengine: at_hdmac: Protect atchan->status with the channel lock Date: Tue, 25 Oct 2022 12:02:40 +0300 Message-ID: <20221025090306.297886-7-tudor.ambarus@microchip.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221025090306.297886-1-tudor.ambarus@microchip.com> References: <20221025090306.297886-1-tudor.ambarus@microchip.com> MIME-Version: 1.0 X-Spam-Status: No, score=-4.9 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,URIBL_BLOCKED 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747649926704727129?= X-GMAIL-MSGID: =?utf-8?q?1747649926704727129?= 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 11816484843e..deb4c6027436 100644 --- a/drivers/dma/at_hdmac.c +++ b/drivers/dma/at_hdmac.c @@ -1460,12 +1460,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; }