提交 a3c5578f 编写于 作者: D Dāvis Mosāns 提交者: Zheng Zengkai

crypto: ccp - ccp_dmaengine_unregister release dma channels

stable inclusion
from stable-v5.10.110
commit 78622926fe01363d78b0f861bfa5c35223c0a645
bugzilla: https://gitee.com/openeuler/kernel/issues/I574AL

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=78622926fe01363d78b0f861bfa5c35223c0a645

--------------------------------

[ Upstream commit 54cce8ec ]

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: 58ea8abf ("crypto: ccp - Register the CCP as a DMA...")
Signed-off-by: NDāvis Mosāns <davispuh@gmail.com>
Acked-by: NJohn Allen <john.allen@amd.com>
Signed-off-by: NHerbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: NSasha Levin <sashal@kernel.org>
Signed-off-by: NYu Liao <liaoyu15@huawei.com>
Reviewed-by: NWei Li <liwei391@huawei.com>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
上级 501679e0
...@@ -633,6 +633,20 @@ static int ccp_terminate_all(struct dma_chan *dma_chan) ...@@ -633,6 +633,20 @@ static int ccp_terminate_all(struct dma_chan *dma_chan)
return 0; 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) int ccp_dmaengine_register(struct ccp_device *ccp)
{ {
struct ccp_dma_chan *chan; struct ccp_dma_chan *chan;
...@@ -737,6 +751,7 @@ int ccp_dmaengine_register(struct ccp_device *ccp) ...@@ -737,6 +751,7 @@ int ccp_dmaengine_register(struct ccp_device *ccp)
return 0; return 0;
err_reg: err_reg:
ccp_dma_release(ccp);
kmem_cache_destroy(ccp->dma_desc_cache); kmem_cache_destroy(ccp->dma_desc_cache);
err_cache: err_cache:
...@@ -753,6 +768,7 @@ void ccp_dmaengine_unregister(struct ccp_device *ccp) ...@@ -753,6 +768,7 @@ void ccp_dmaengine_unregister(struct ccp_device *ccp)
return; return;
dma_async_device_unregister(dma_dev); dma_async_device_unregister(dma_dev);
ccp_dma_release(ccp);
kmem_cache_destroy(ccp->dma_desc_cache); kmem_cache_destroy(ccp->dma_desc_cache);
kmem_cache_destroy(ccp->dma_cmd_cache); kmem_cache_destroy(ccp->dma_cmd_cache);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册