Commit d095146c authored by Horia Geantă's avatar Horia Geantă Committed by Herbert Xu

crypto: caam/qi2 - fix return code in ahash_finup_no_ctx()

ahash_finup_no_ctx() returns -ENOMEM in most error cases,
and this is fine for almost all of them.

However, the return code provided by dpaa2_caam_enqueue()
(e.g. -EIO or -EBUSY) shouldn't be overridden by -ENOMEM.
Signed-off-by: default avatarHoria Geantă <horia.geanta@nxp.com>
Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
parent 84d840e1
...@@ -4004,7 +4004,7 @@ static int ahash_finup_no_ctx(struct ahash_request *req) ...@@ -4004,7 +4004,7 @@ static int ahash_finup_no_ctx(struct ahash_request *req)
int digestsize = crypto_ahash_digestsize(ahash); int digestsize = crypto_ahash_digestsize(ahash);
struct ahash_edesc *edesc; struct ahash_edesc *edesc;
struct dpaa2_sg_entry *sg_table; struct dpaa2_sg_entry *sg_table;
int ret; int ret = -ENOMEM;
src_nents = sg_nents_for_len(req->src, req->nbytes); src_nents = sg_nents_for_len(req->src, req->nbytes);
if (src_nents < 0) { if (src_nents < 0) {
...@@ -4017,7 +4017,7 @@ static int ahash_finup_no_ctx(struct ahash_request *req) ...@@ -4017,7 +4017,7 @@ static int ahash_finup_no_ctx(struct ahash_request *req)
DMA_TO_DEVICE); DMA_TO_DEVICE);
if (!mapped_nents) { if (!mapped_nents) {
dev_err(ctx->dev, "unable to DMA map source\n"); dev_err(ctx->dev, "unable to DMA map source\n");
return -ENOMEM; return ret;
} }
} else { } else {
mapped_nents = 0; mapped_nents = 0;
...@@ -4027,7 +4027,7 @@ static int ahash_finup_no_ctx(struct ahash_request *req) ...@@ -4027,7 +4027,7 @@ static int ahash_finup_no_ctx(struct ahash_request *req)
edesc = qi_cache_zalloc(GFP_DMA | flags); edesc = qi_cache_zalloc(GFP_DMA | flags);
if (!edesc) { if (!edesc) {
dma_unmap_sg(ctx->dev, req->src, src_nents, DMA_TO_DEVICE); dma_unmap_sg(ctx->dev, req->src, src_nents, DMA_TO_DEVICE);
return -ENOMEM; return ret;
} }
edesc->src_nents = src_nents; edesc->src_nents = src_nents;
...@@ -4044,6 +4044,7 @@ static int ahash_finup_no_ctx(struct ahash_request *req) ...@@ -4044,6 +4044,7 @@ static int ahash_finup_no_ctx(struct ahash_request *req)
DMA_TO_DEVICE); DMA_TO_DEVICE);
if (dma_mapping_error(ctx->dev, edesc->qm_sg_dma)) { if (dma_mapping_error(ctx->dev, edesc->qm_sg_dma)) {
dev_err(ctx->dev, "unable to map S/G table\n"); dev_err(ctx->dev, "unable to map S/G table\n");
ret = -ENOMEM;
goto unmap; goto unmap;
} }
edesc->qm_sg_bytes = qm_sg_bytes; edesc->qm_sg_bytes = qm_sg_bytes;
...@@ -4054,6 +4055,7 @@ static int ahash_finup_no_ctx(struct ahash_request *req) ...@@ -4054,6 +4055,7 @@ static int ahash_finup_no_ctx(struct ahash_request *req)
if (dma_mapping_error(ctx->dev, state->ctx_dma)) { if (dma_mapping_error(ctx->dev, state->ctx_dma)) {
dev_err(ctx->dev, "unable to map ctx\n"); dev_err(ctx->dev, "unable to map ctx\n");
state->ctx_dma = 0; state->ctx_dma = 0;
ret = -ENOMEM;
goto unmap; goto unmap;
} }
...@@ -4080,7 +4082,7 @@ static int ahash_finup_no_ctx(struct ahash_request *req) ...@@ -4080,7 +4082,7 @@ static int ahash_finup_no_ctx(struct ahash_request *req)
unmap: unmap:
ahash_unmap_ctx(ctx->dev, edesc, req, DMA_FROM_DEVICE); ahash_unmap_ctx(ctx->dev, edesc, req, DMA_FROM_DEVICE);
qi_cache_free(edesc); qi_cache_free(edesc);
return -ENOMEM; return ret;
} }
static int ahash_update_first(struct ahash_request *req) static int ahash_update_first(struct ahash_request *req)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment