Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp704705pxb; Tue, 5 Apr 2022 19:33:13 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyADSghdWeeiKDiUgkBXF4/ktbYGZEaRuRBJ3GtUI8hngkrDlOoduDV5dRm2ZubKwH/IquM X-Received: by 2002:a17:903:248:b0:155:e660:b774 with SMTP id j8-20020a170903024800b00155e660b774mr6553686plh.174.1649212393006; Tue, 05 Apr 2022 19:33:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649212393; cv=none; d=google.com; s=arc-20160816; b=QAxlGItElIROQbxjFv+hQwAQJmzKF3WdUDA0s2rYRIf+rSbKsYa5nhOP91z2O66zS5 CQCoI5opWcmBgCKGW5yKj9e1TNEOPPuncQje4+Cp+DIyQKCx/CxPf05bcQtpR7hu9Y5U 2Yms2zm0VFMS9tCPme0n5qgER544hDF3yKlUX1RXhOsho9yzFU1SbQLhUN97LDnaAcKR iHfaXVkSujJK0InjF1ny9fp9FMkWlolQxXgTLIaVz9dgLPqupkW89r4wlWhkTl1ycg1v JenIMQVA0C49n+yriRLUHDT4kSb+muP+ETFnd+g//SKhj9bAYItj9ZzhOX9cmcGtJZq/ nhQA== 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=ZNT29X3PjcwurDsGZNOI3TfSppqkrgQN8enU/ttrXB4P9Q66lW2hBXtljYCSVT2E3u B1S9GFo39MPWFcJne/CnZK9Gflcz/77sv9LDQOe3srSpY3SkRBX1/OGzIMXfdGHG1sQY kXmcdet+SSsm2lo1k37n/z0/ncLJU02tJVKOQjJy6K6EcwSSb6sOvxjoNxb7evG8JB9E q/9cfhVhYH+74DuLjRfHrVz/KBKEqKKV+hBXKa0a1xihWFc6l3haB9aSEPHXZF8j/5q4 ZfgYvqg6/ZsnIie2LEgQNYYSXkN9XujfnDTa0/uRIun57/C51c0amhG75FIiJ4aW05oe 2yNA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=0mHJb9yT; 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 s12-20020a056a00178c00b004fa744877dasi16531807pfg.39.2022.04.05.19.32.59; Tue, 05 Apr 2022 19:33: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=@linuxfoundation.org header.s=korg header.b=0mHJb9yT; 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 S234622AbiDEINo (ORCPT + 99 others); Tue, 5 Apr 2022 04:13:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55916 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234509AbiDEH6h (ORCPT ); Tue, 5 Apr 2022 03:58:37 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AACB5A5E9E; Tue, 5 Apr 2022 00:52:38 -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 205136172C; Tue, 5 Apr 2022 07:52:38 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2764DC340EE; Tue, 5 Apr 2022 07:52:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649145157; bh=QdZzKpYR0Ak0Jkw0efMXTY/uKg67msQsuJfRVbPyVW4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=0mHJb9yTjgJAwsn3tBEhqlW3XmUNawgFh4/4ygZZxACXXRYYpZUroHG/5z/jzkNtE KJ/r3dwzoyQGBh5FLzvs+Mev3PgA5PbxKBO9l5ONQEvY9eg9ROoU3fYfg4Biz0JlRg lOGVywluG2PmwiDOXXg3EKkh6Zk4cl3Yd2JzHIps= 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.17 0257/1126] crypto: ccp - ccp_dmaengine_unregister release dma channels Date: Tue, 5 Apr 2022 09:16:44 +0200 Message-Id: <20220405070415.154399786@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220405070407.513532867@linuxfoundation.org> References: <20220405070407.513532867@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