diff options
author | Antoine Tenart <antoine.tenart@bootlin.com> | 2018-03-19 09:21:16 +0100 |
---|---|---|
committer | Herbert Xu <herbert@gondor.apana.org.au> | 2018-03-30 19:32:45 +0200 |
commit | 57433b582090ce0d751009e931f15a653e22ee85 (patch) | |
tree | f9821e182b44ad2e0623314b0a7d851b8cf0c5fa | |
parent | crypto: inside-secure - fix a typo in a register name (diff) | |
download | linux-57433b582090ce0d751009e931f15a653e22ee85.tar.xz linux-57433b582090ce0d751009e931f15a653e22ee85.zip |
crypto: inside-secure - improve the send error path
This patch improves the send error path as it wasn't handling all error
cases. A new label is added, and some of the goto are updated to point
to the right labels, so that the code is more robust to errors.
Signed-off-by: Antoine Tenart <antoine.tenart@bootlin.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
-rw-r--r-- | drivers/crypto/inside-secure/safexcel_hash.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/drivers/crypto/inside-secure/safexcel_hash.c b/drivers/crypto/inside-secure/safexcel_hash.c index 955b25ebffee..ee4caf34c5a7 100644 --- a/drivers/crypto/inside-secure/safexcel_hash.c +++ b/drivers/crypto/inside-secure/safexcel_hash.c @@ -281,7 +281,7 @@ static int safexcel_ahash_send_req(struct crypto_async_request *async, int ring, sglen, len, ctx->base.ctxr_dma); if (IS_ERR(cdesc)) { ret = PTR_ERR(cdesc); - goto cdesc_rollback; + goto unmap_sg; } n_cdesc++; @@ -305,7 +305,7 @@ send_command: DMA_FROM_DEVICE); if (dma_mapping_error(priv->dev, req->result_dma)) { ret = -EINVAL; - goto cdesc_rollback; + goto unmap_sg; } /* Add a result descriptor */ @@ -326,6 +326,9 @@ send_command: return 0; unmap_result: + dma_unmap_single(priv->dev, req->result_dma, req->state_sz, + DMA_FROM_DEVICE); +unmap_sg: dma_unmap_sg(priv->dev, areq->src, req->nents, DMA_TO_DEVICE); cdesc_rollback: for (i = 0; i < n_cdesc; i++) |