Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp676569pxb; Tue, 5 Apr 2022 18:20:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzkJqR4XmVgCDaBi+IGjDhPDtVBuS7FOyssx4L7yFOewHHFT1Uu5Ia1FMbfZS6rO/rqb73g X-Received: by 2002:a05:6402:f16:b0:419:d9f3:f8b with SMTP id i22-20020a0564020f1600b00419d9f30f8bmr6405176eda.33.1649208030587; Tue, 05 Apr 2022 18:20:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649208030; cv=none; d=google.com; s=arc-20160816; b=0Md0Gz29I1598oGCdv+9DF/90P3VL0sx5hQB9NKLN9NUmh85xkWow4clVB6hbPOTJ0 oyS4biMZ+H048Kut/CKS957loCLQP/b+8cn5Zya9YaafuQjhE0UU+93l6qum5f8jrs1u Za8PpdfQfb05W54+0NkGZYNlCtWnQj1SiyHeivFMV3q7iSqbcI2FUZZ2EWAXE0EIDLsc uCMyqiEDJogisgWBB8/S7jiCkT0nr5+ignQDv3lwhdD7qoxwL3Pe9LeSerf0cU7FTuQu k4mlL8TsjVsjZCAIX+lJfyqddhURgC3ScmfK4bLOxlWZxJvnTlU7A6N4uPReClT2NZLZ fkwQ== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=BzZwv5ALR8lKNBDqqii9tqgNPZT8ZdLib3vZS5lOik8=; b=xecel745VoVW+SkCSRE9Kg7PKit6XiqfFDtVfEiSsxG/h6Rs/KyDy68wd83EyT02Ll t0THKmcqZUXxpmC6DU/HqqlWp+OUr13QQKRKEbFZqEWVTzqzFq8PkrsWjstGLY6GlRgz 4Fj3Bx5r2R6WUX8pl3y1SCKP9/cb9DH6bJuQ8RITg7xM2UPvBuxIiM+0EIbPaXWU94Qo zYg6y/HzzLaUAkJEezLCZq3dKE+c1OS3Oe9OAJ0O5j43pHkaUfhUQpYU6MoxbriYdIFs EYBFN5GQHu+JN84lGbvyHnga/1Q95XQk+MbObirfPdpQSbY8QCJs5IAYq5kbaGNPM8SJ o+dw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=eSkkqc+j; 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=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n26-20020aa7c45a000000b00418fe90d5e1si10944899edr.431.2022.04.05.18.19.58; Tue, 05 Apr 2022 18:20:30 -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=@linuxfoundation.org header.s=korg header.b=eSkkqc+j; 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=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1378835AbiDELjP (ORCPT + 99 others); Tue, 5 Apr 2022 07:39:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51012 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244716AbiDEIwf (ORCPT ); Tue, 5 Apr 2022 04:52:35 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6CED31705A; Tue, 5 Apr 2022 01:42:27 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 07B986117A; Tue, 5 Apr 2022 08:42:27 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 13179C385A1; Tue, 5 Apr 2022 08:42:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649148146; bh=QdZzKpYR0Ak0Jkw0efMXTY/uKg67msQsuJfRVbPyVW4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=eSkkqc+jHI3C2me6fhr0oC5VnrhTN74dSo04TOaHbt7X9ooODrYQ5Qqyfx8ipvATY l0lD04uBewF+hRuWEeF65w6pFlorX+WnBOUGu8Y43EC5W088zV0hUHsfNk4drMLfrG WkWfZQb64aYuItRSTIWiIuP5/T/c5q5/C0/+1IDY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, =?UTF-8?q?D=C4=81vis=20Mos=C4=81ns?= , John Allen , Herbert Xu , Sasha Levin Subject: [PATCH 5.16 0250/1017] crypto: ccp - ccp_dmaengine_unregister release dma channels Date: Tue, 5 Apr 2022 09:19:23 +0200 Message-Id: <20220405070401.682234856@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220405070354.155796697@linuxfoundation.org> References: <20220405070354.155796697@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,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 From: Dāvis Mosāns [ Upstream commit 54cce8ecb9254f971b40a72911c6da403720a2d2 ] ccp_dmaengine_register adds dma_chan->device_node to dma_dev->channels list but ccp_dmaengine_unregister didn't remove them. That can cause crashes in various dmaengine methods that tries to use dma_dev->channels Fixes: 58ea8abf4904 ("crypto: ccp - Register the CCP as a DMA...") Signed-off-by: Dāvis Mosāns Acked-by: John Allen Signed-off-by: Herbert Xu Signed-off-by: Sasha Levin --- drivers/crypto/ccp/ccp-dmaengine.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/drivers/crypto/ccp/ccp-dmaengine.c b/drivers/crypto/ccp/ccp-dmaengine.c index d718db224be4..7d4b4ad1db1f 100644 --- a/drivers/crypto/ccp/ccp-dmaengine.c +++ b/drivers/crypto/ccp/ccp-dmaengine.c @@ -632,6 +632,20 @@ static int ccp_terminate_all(struct dma_chan *dma_chan) return 0; } +static void ccp_dma_release(struct ccp_device *ccp) +{ + struct ccp_dma_chan *chan; + struct dma_chan *dma_chan; + unsigned int i; + + for (i = 0; i < ccp->cmd_q_count; i++) { + chan = ccp->ccp_dma_chan + i; + dma_chan = &chan->dma_chan; + tasklet_kill(&chan->cleanup_tasklet); + list_del_rcu(&dma_chan->device_node); + } +} + int ccp_dmaengine_register(struct ccp_device *ccp) { struct ccp_dma_chan *chan; @@ -736,6 +750,7 @@ int ccp_dmaengine_register(struct ccp_device *ccp) return 0; err_reg: + ccp_dma_release(ccp); kmem_cache_destroy(ccp->dma_desc_cache); err_cache: @@ -752,6 +767,7 @@ void ccp_dmaengine_unregister(struct ccp_device *ccp) return; dma_async_device_unregister(dma_dev); + ccp_dma_release(ccp); kmem_cache_destroy(ccp->dma_desc_cache); kmem_cache_destroy(ccp->dma_cmd_cache); -- 2.34.1