summaryrefslogtreecommitdiff
path: root/drivers/crypto
diff options
context:
space:
mode:
authorAymen Sghaier <aymen.sghaier@nxp.com>2018-06-26 15:46:43 +0200
committerJason Liu <jason.hui.liu@nxp.com>2018-10-29 11:10:38 +0800
commitf91e321f1ac101491b760390ae3ae23a97e79d07 (patch)
tree7d40fd43e30f6a185d5a5cef33098c6b93e3a214 /drivers/crypto
parent1e9a135cef73af9f80999ed7e4044a69cf2d92eb (diff)
MLK-17304-3: crypto: caam: Avoid dma_map call with empty buffer
While testing CONFIG_CRYPTO_MANAGER_DISABLE_TESTS, a Kernel panic occurred at caamhash module. The cause was the call of dma_map with empty buffer. This fix the issue by checking for size before dma_map. Signed-off-by: Aymen Sghaier <aymen.sghaier@nxp.com>
Diffstat (limited to 'drivers/crypto')
-rw-r--r--drivers/crypto/caam/caamhash.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/drivers/crypto/caam/caamhash.c b/drivers/crypto/caam/caamhash.c
index 38956fa60b66..3a091dd615d1 100644
--- a/drivers/crypto/caam/caamhash.c
+++ b/drivers/crypto/caam/caamhash.c
@@ -1334,13 +1334,16 @@ static int ahash_final_no_ctx(struct ahash_request *req)
desc = edesc->hw_desc;
- state->buf_dma = dma_map_single(jrdev, buf, buflen, DMA_TO_DEVICE);
- if (dma_mapping_error(jrdev, state->buf_dma)) {
- dev_err(jrdev, "unable to map src\n");
- goto unmap;
- }
+ if (buflen) {
+ state->buf_dma = dma_map_single(jrdev, buf, buflen,
+ DMA_TO_DEVICE);
+ if (dma_mapping_error(jrdev, state->buf_dma)) {
+ dev_err(jrdev, "unable to map src\n");
+ goto unmap;
+ }
- append_seq_in_ptr(desc, state->buf_dma, buflen, 0);
+ append_seq_in_ptr(desc, state->buf_dma, buflen, 0);
+ }
edesc->dst_dma = map_seq_out_ptr_result(desc, jrdev, req->result,
digestsize);