提交 c5f39d07 编写于 作者: G Gilad Ben-Yossef 提交者: Greg Kroah-Hartman

staging: ccree: fix leak of import() after init()

crypto_ahash_import() may be called either after
crypto_ahash_init() or without such call. Right now
we always internally call init() as part of
import(), thus leaking memory and mappings if the
user has already called init() herself.

Fix this by only calling init() internally if the
state is not already initialized.

Fixes: commit 454527d0 ("staging: ccree: fix hash import/export")
Cc: stable <stable@vger.kernel.org>
Signed-off-by: NGilad Ben-Yossef <gilad@benyossef.com>
Reviewed-by: NDan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
上级 02d69c03
...@@ -1778,9 +1778,12 @@ static int ssi_ahash_import(struct ahash_request *req, const void *in) ...@@ -1778,9 +1778,12 @@ static int ssi_ahash_import(struct ahash_request *req, const void *in)
} }
in += sizeof(u32); in += sizeof(u32);
rc = ssi_hash_init(state, ctx); /* call init() to allocate bufs if the user hasn't */
if (rc) if (!state->digest_buff) {
goto out; rc = ssi_hash_init(state, ctx);
if (rc)
goto out;
}
dma_sync_single_for_cpu(dev, state->digest_buff_dma_addr, dma_sync_single_for_cpu(dev, state->digest_buff_dma_addr,
ctx->inter_digestsize, DMA_BIDIRECTIONAL); ctx->inter_digestsize, DMA_BIDIRECTIONAL);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册