]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - releases/4.19.31/crypto-ccree-fix-free-of-unallocated-mlli-buffer.patch
Linux 4.14.108
[thirdparty/kernel/stable-queue.git] / releases / 4.19.31 / crypto-ccree-fix-free-of-unallocated-mlli-buffer.patch
1 From a49411959ea6d4915a9fd2a7eb5ba220e6284e9a Mon Sep 17 00:00:00 2001
2 From: Hadar Gat <hadar.gat@arm.com>
3 Date: Tue, 15 Jan 2019 15:43:13 +0200
4 Subject: crypto: ccree - fix free of unallocated mlli buffer
5
6 From: Hadar Gat <hadar.gat@arm.com>
7
8 commit a49411959ea6d4915a9fd2a7eb5ba220e6284e9a upstream.
9
10 In cc_unmap_aead_request(), call dma_pool_free() for mlli buffer only
11 if an item is allocated from the pool and not always if there is a
12 pool allocated.
13 This fixes a kernel panic when trying to free a non-allocated item.
14
15 Cc: stable@vger.kernel.org
16 Signed-off-by: Hadar Gat <hadar.gat@arm.com>
17 Signed-off-by: Gilad Ben-Yossef <gilad@benyossef.com>
18 Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
19 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
20
21 ---
22 drivers/crypto/ccree/cc_buffer_mgr.c | 8 ++++----
23 1 file changed, 4 insertions(+), 4 deletions(-)
24
25 --- a/drivers/crypto/ccree/cc_buffer_mgr.c
26 +++ b/drivers/crypto/ccree/cc_buffer_mgr.c
27 @@ -614,10 +614,10 @@ void cc_unmap_aead_request(struct device
28 hw_iv_size, DMA_BIDIRECTIONAL);
29 }
30
31 - /*In case a pool was set, a table was
32 - *allocated and should be released
33 - */
34 - if (areq_ctx->mlli_params.curr_pool) {
35 + /* Release pool */
36 + if ((areq_ctx->assoc_buff_type == CC_DMA_BUF_MLLI ||
37 + areq_ctx->data_buff_type == CC_DMA_BUF_MLLI) &&
38 + (areq_ctx->mlli_params.mlli_virt_addr)) {
39 dev_dbg(dev, "free MLLI buffer: dma=%pad virt=%pK\n",
40 &areq_ctx->mlli_params.mlli_dma_addr,
41 areq_ctx->mlli_params.mlli_virt_addr);