* [PATCH][V2] crypto: sa2ul: Fix memory leak of rxd
@ 2021-04-01 15:28 Colin King
2021-04-09 7:54 ` Herbert Xu
0 siblings, 1 reply; 2+ messages in thread
From: Colin King @ 2021-04-01 15:28 UTC (permalink / raw)
To: Herbert Xu, David S . Miller, Peter Ujfalusi, linux-crypto
Cc: kernel-janitors, linux-kernel
From: Colin Ian King <colin.king@canonical.com>
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>
---
V2: Fix typo in $SUBJECT
---
drivers/crypto/sa2ul.c | 8 ++++++--
1 file 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;
--
2.30.2
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH][V2] crypto: sa2ul: Fix memory leak of rxd
2021-04-01 15:28 [PATCH][V2] crypto: sa2ul: Fix memory leak of rxd Colin King
@ 2021-04-09 7:54 ` Herbert Xu
0 siblings, 0 replies; 2+ messages in thread
From: Herbert Xu @ 2021-04-09 7:54 UTC (permalink / raw)
To: Colin King
Cc: David S . Miller, Peter Ujfalusi, linux-crypto, kernel-janitors,
linux-kernel
On Thu, Apr 01, 2021 at 04:28:39PM +0100, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> 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>
> ---
>
> V2: Fix typo in $SUBJECT
>
> ---
> drivers/crypto/sa2ul.c | 8 ++++++--
> 1 file changed, 6 insertions(+), 2 deletions(-)
Patch applied. Thanks.
--
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-04-09 7:54 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-01 15:28 [PATCH][V2] crypto: sa2ul: Fix memory leak of rxd Colin King
2021-04-09 7:54 ` Herbert Xu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).