summaryrefslogtreecommitdiff
path: root/drivers/crypto/sa2ul.c
diff options
context:
space:
mode:
authorColin Ian King <colin.king@canonical.com>2021-04-01 16:28:39 +0100
committerHerbert Xu <herbert@gondor.apana.org.au>2021-04-09 17:45:13 +1000
commit854b7737199848a91f6adfa0a03cf6f0c46c86e8 (patch)
tree2492f2990f1bfac784411784f9786c90bea78751 /drivers/crypto/sa2ul.c
parent50274b01ac1689b1a3f6bc4b5b3dbf361a55dd3a (diff)
crypto: sa2ul - Fix memory leak of rxd
There are two error return paths that are not freeing rxd and causing memory leaks. Fix these. Addresses-Coverity: ("Resource leak") Fixes: 00c9211f60db ("crypto: sa2ul - Fix DMA mapping API usage") Signed-off-by: Colin Ian King <colin.king@canonical.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'drivers/crypto/sa2ul.c')
-rw-r--r--drivers/crypto/sa2ul.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/drivers/crypto/sa2ul.c b/drivers/crypto/sa2ul.c
index f300b0a5958a..ca7484aac727 100644
--- a/drivers/crypto/sa2ul.c
+++ b/drivers/crypto/sa2ul.c
@@ -1146,8 +1146,10 @@ static int sa_run(struct sa_req *req)
mapped_sg->sgt.sgl = src;
mapped_sg->sgt.orig_nents = src_nents;
ret = dma_map_sgtable(ddev, &mapped_sg->sgt, dir_src, 0);
- if (ret)
+ if (ret) {
+ kfree(rxd);
return ret;
+ }
mapped_sg->dir = dir_src;
mapped_sg->mapped = true;
@@ -1155,8 +1157,10 @@ static int sa_run(struct sa_req *req)
mapped_sg->sgt.sgl = req->src;
mapped_sg->sgt.orig_nents = sg_nents;
ret = dma_map_sgtable(ddev, &mapped_sg->sgt, dir_src, 0);
- if (ret)
+ if (ret) {
+ kfree(rxd);
return ret;
+ }
mapped_sg->dir = dir_src;
mapped_sg->mapped = true;