Commit 26d52ea3 authored by Tadeusz Struk's avatar Tadeusz Struk Committed by Herbert Xu

crypto: qat - fix leak on error path

Fix a leak on error path in qat asym
Reported-by: default avatarSalvatore Benedetto <salvatore.benedetto@intel.com>
Signed-off-by: default avatarTadeusz Struk <tadeusz.struk@intel.com>
Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
parent 28856a9e
...@@ -340,13 +340,15 @@ static int qat_rsa_enc(struct akcipher_request *req) ...@@ -340,13 +340,15 @@ static int qat_rsa_enc(struct akcipher_request *req)
if (!ret) if (!ret)
return -EINPROGRESS; return -EINPROGRESS;
unmap_src:
if (qat_req->src_align) if (!dma_mapping_error(dev, qat_req->phy_out))
dma_free_coherent(dev, ctx->key_sz, qat_req->src_align, dma_unmap_single(dev, qat_req->phy_out,
qat_req->in.enc.m); sizeof(struct qat_rsa_output_params),
else DMA_TO_DEVICE);
if (!dma_mapping_error(dev, qat_req->in.enc.m)) unmap_in_params:
dma_unmap_single(dev, qat_req->in.enc.m, ctx->key_sz, if (!dma_mapping_error(dev, qat_req->phy_in))
dma_unmap_single(dev, qat_req->phy_in,
sizeof(struct qat_rsa_input_params),
DMA_TO_DEVICE); DMA_TO_DEVICE);
unmap_dst: unmap_dst:
if (qat_req->dst_align) if (qat_req->dst_align)
...@@ -356,14 +358,13 @@ static int qat_rsa_enc(struct akcipher_request *req) ...@@ -356,14 +358,13 @@ static int qat_rsa_enc(struct akcipher_request *req)
if (!dma_mapping_error(dev, qat_req->out.enc.c)) if (!dma_mapping_error(dev, qat_req->out.enc.c))
dma_unmap_single(dev, qat_req->out.enc.c, ctx->key_sz, dma_unmap_single(dev, qat_req->out.enc.c, ctx->key_sz,
DMA_FROM_DEVICE); DMA_FROM_DEVICE);
unmap_in_params: unmap_src:
if (!dma_mapping_error(dev, qat_req->phy_in)) if (qat_req->src_align)
dma_unmap_single(dev, qat_req->phy_in, dma_free_coherent(dev, ctx->key_sz, qat_req->src_align,
sizeof(struct qat_rsa_input_params), qat_req->in.enc.m);
DMA_TO_DEVICE); else
if (!dma_mapping_error(dev, qat_req->phy_out)) if (!dma_mapping_error(dev, qat_req->in.enc.m))
dma_unmap_single(dev, qat_req->phy_out, dma_unmap_single(dev, qat_req->in.enc.m, ctx->key_sz,
sizeof(struct qat_rsa_output_params),
DMA_TO_DEVICE); DMA_TO_DEVICE);
return ret; return ret;
} }
...@@ -472,13 +473,15 @@ static int qat_rsa_dec(struct akcipher_request *req) ...@@ -472,13 +473,15 @@ static int qat_rsa_dec(struct akcipher_request *req)
if (!ret) if (!ret)
return -EINPROGRESS; return -EINPROGRESS;
unmap_src:
if (qat_req->src_align) if (!dma_mapping_error(dev, qat_req->phy_out))
dma_free_coherent(dev, ctx->key_sz, qat_req->src_align, dma_unmap_single(dev, qat_req->phy_out,
qat_req->in.dec.c); sizeof(struct qat_rsa_output_params),
else DMA_TO_DEVICE);
if (!dma_mapping_error(dev, qat_req->in.dec.c)) unmap_in_params:
dma_unmap_single(dev, qat_req->in.dec.c, ctx->key_sz, if (!dma_mapping_error(dev, qat_req->phy_in))
dma_unmap_single(dev, qat_req->phy_in,
sizeof(struct qat_rsa_input_params),
DMA_TO_DEVICE); DMA_TO_DEVICE);
unmap_dst: unmap_dst:
if (qat_req->dst_align) if (qat_req->dst_align)
...@@ -488,14 +491,13 @@ static int qat_rsa_dec(struct akcipher_request *req) ...@@ -488,14 +491,13 @@ static int qat_rsa_dec(struct akcipher_request *req)
if (!dma_mapping_error(dev, qat_req->out.dec.m)) if (!dma_mapping_error(dev, qat_req->out.dec.m))
dma_unmap_single(dev, qat_req->out.dec.m, ctx->key_sz, dma_unmap_single(dev, qat_req->out.dec.m, ctx->key_sz,
DMA_FROM_DEVICE); DMA_FROM_DEVICE);
unmap_in_params: unmap_src:
if (!dma_mapping_error(dev, qat_req->phy_in)) if (qat_req->src_align)
dma_unmap_single(dev, qat_req->phy_in, dma_free_coherent(dev, ctx->key_sz, qat_req->src_align,
sizeof(struct qat_rsa_input_params), qat_req->in.dec.c);
DMA_TO_DEVICE); else
if (!dma_mapping_error(dev, qat_req->phy_out)) if (!dma_mapping_error(dev, qat_req->in.dec.c))
dma_unmap_single(dev, qat_req->phy_out, dma_unmap_single(dev, qat_req->in.dec.c, ctx->key_sz,
sizeof(struct qat_rsa_output_params),
DMA_TO_DEVICE); DMA_TO_DEVICE);
return ret; return ret;
} }
......
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