Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp3029489pxb; Mon, 18 Apr 2022 13:56:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzvuTDJVB5YUiZ3zUn2P+clG3KojUspwCpvr9tHWWjU2wtmxiV9zfeutL2VVxAB4JryFTQq X-Received: by 2002:a17:902:8490:b0:156:7eb1:33c7 with SMTP id c16-20020a170902849000b001567eb133c7mr12297266plo.39.1650315372736; Mon, 18 Apr 2022 13:56:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650315372; cv=none; d=google.com; s=arc-20160816; b=O3uUKOY5EN1EUCs43GxvGpefIMFBo8V6bUsM/CpaeUwEyCzxhBmVFcd+0EC6Q+lWzY Bf7lnm+sbMQevzYuzOGFaivT5D0sojHqh1y0k9+n2WwP1EGOKPs9VbHpfSs+9nFtBf7p QVrSAwhFYDkbXZbkSMjm2+Mv7kdTQTq5yPdo7a9Yo0u71pEbtZ5GG9EXcNuRpLd/jUMi xyNrX+5iHuB8MhKtzZOZVCH/07Cz74o/9jEFE9etQDcjxdSc7cc9YSs4UDFHjBQ8ERFD 1vsi87SEQFEqGfVTWXGyI9asjPOWucMxjLtbreimROiSrWt1gkOUPu7Vj+GQDYxA59Ia Cv+A== 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=MY4aaCpF12QPhO2TYLXp5pc74hlVXoFpOCXO9iAERzc=; b=TaSWCjSAYhzzOcJCo02kjhOkDbbvMVT/ixkdUBRWz6hlR/k0IntnYuiTcaY0ihMtn3 3+LbWcmHzlNuIwnDtTjCD4HLEu6Z7s62QntFq3oQDkMwrhoyxs6+RvtxKsXVFT1a+3aE P9BAZtcIOaaGWZmOG9oBQ6VfVnPRnAed1n1zU6gGFSwilndojLxYaFlqCAh3VXwlGVBN z4DdlWkLBgbYYBLjnDEaVmMG5gCA2PEb0g/OpKLndXyS7/0S+Hb9NQTMYX/LCNN/XTxf 5FZFyoIwheNBTs2p/HezjQ6Qsd79YQcDFMlnH6xKEHQWWXEXkWR4u+nCKSJNzpI/V4xA TAGg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="ZrLjJ/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 q7-20020a056a00084700b004faa8ee4f05si11110199pfk.98.2022.04.18.13.55.57; Mon, 18 Apr 2022 13:56: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="ZrLjJ/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 S244077AbiDRNiz (ORCPT + 99 others); Mon, 18 Apr 2022 09:38:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53244 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243985AbiDRNKk (ORCPT ); Mon, 18 Apr 2022 09:10:40 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5608B39681; Mon, 18 Apr 2022 05:50:18 -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 2460E61254; Mon, 18 Apr 2022 12:50:18 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2C4F3C385A1; Mon, 18 Apr 2022 12:50:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1650286217; bh=VJ0BUAhS3wNyh0DC82txMyIdsjCD3fgIBqLn4GwapDY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZrLjJ/j+b0lla1hjMxMzs+n5498+r1zaVr88eAd6O0NJWH2VzJ0ztxawvxYMQjaNH JwTz6KkdkMVUrvvIgYBLNVkPRHn8YRVYznv54iF7TZvXCTez7AiJF0Bvi5cbwfikHr e7cjJx1SJS0uBI9ARS3ZZShdxpmozEZAa4C/tz3M= 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 4.14 065/284] crypto: ccp - ccp_dmaengine_unregister release dma channels Date: Mon, 18 Apr 2022 14:10:46 +0200 Message-Id: <20220418121212.539249298@linuxfoundation.org> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220418121210.689577360@linuxfoundation.org> References: <20220418121210.689577360@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.7 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 df82af3dd970..27a738c57119 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; @@ -733,6 +747,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: @@ -746,6 +761,7 @@ void ccp_dmaengine_unregister(struct ccp_device *ccp) struct dma_device *dma_dev = &ccp->dma_dev; 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