Skip to contentSkip to conversation

crypto: sa2ul: Fix memory lead of rxd

PATCH New Colin King 1 participant 1 message Apr 1, 2021

Subsystems (2)
lore
Share & tools
lore

Colin King

author
#0 lore raw

PATCH 1/1 crypto: sa2ul: Fix memory lead of rxd

From: Colin Ian King <[email protected]>

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")
---
 drivers/crypto/sa2ul.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/crypto/sa2ul.c +6 -2
index f300b0a5958a..ca7484aac727 100644
@@ -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;
Signature · 1 line
2.30.2