linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH][next] crypto: sun8i-ss: Fix memory leak of pad
@ 2021-04-01 15:18 Colin King
  2021-04-02 11:18 ` Corentin Labbe
  2021-04-09  7:54 ` Herbert Xu
  0 siblings, 2 replies; 3+ messages in thread
From: Colin King @ 2021-04-01 15:18 UTC (permalink / raw)
  To: Corentin Labbe, Herbert Xu, David S . Miller, Maxime Ripard,
	Chen-Yu Tsai, Jernej Skrabec, linux-crypto, linux-arm-kernel
  Cc: kernel-janitors, linux-kernel

From: Colin Ian King <colin.king@canonical.com>

It appears there are several failure return paths that don't seem
to be free'ing pad. Fix these.

Addresses-Coverity: ("Resource leak")
Fixes: d9b45418a917 ("crypto: sun8i-ss - support hash algorithms")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 drivers/crypto/allwinner/sun8i-ss/sun8i-ss-hash.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/crypto/allwinner/sun8i-ss/sun8i-ss-hash.c b/drivers/crypto/allwinner/sun8i-ss/sun8i-ss-hash.c
index 7d1fc9aba665..3c073eb3db03 100644
--- a/drivers/crypto/allwinner/sun8i-ss/sun8i-ss-hash.c
+++ b/drivers/crypto/allwinner/sun8i-ss/sun8i-ss-hash.c
@@ -348,8 +348,10 @@ int sun8i_ss_hash_run(struct crypto_engine *engine, void *breq)
 	bf = (__le32 *)pad;
 
 	result = kzalloc(digestsize, GFP_KERNEL | GFP_DMA);
-	if (!result)
+	if (!result) {
+		kfree(pad);
 		return -ENOMEM;
+	}
 
 	for (i = 0; i < MAX_SG; i++) {
 		rctx->t_dst[i].addr = 0;
@@ -436,10 +438,9 @@ int sun8i_ss_hash_run(struct crypto_engine *engine, void *breq)
 		     DMA_TO_DEVICE);
 	dma_unmap_single(ss->dev, addr_res, digestsize, DMA_FROM_DEVICE);
 
-	kfree(pad);
-
 	memcpy(areq->result, result, algt->alg.hash.halg.digestsize);
 theend:
+	kfree(pad);
 	kfree(result);
 	crypto_finalize_hash_request(engine, breq, err);
 	return 0;
-- 
2.30.2


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH][next] crypto: sun8i-ss: Fix memory leak of pad
  2021-04-01 15:18 [PATCH][next] crypto: sun8i-ss: Fix memory leak of pad Colin King
@ 2021-04-02 11:18 ` Corentin Labbe
  2021-04-09  7:54 ` Herbert Xu
  1 sibling, 0 replies; 3+ messages in thread
From: Corentin Labbe @ 2021-04-02 11:18 UTC (permalink / raw)
  To: Colin King
  Cc: Herbert Xu, David S . Miller, Maxime Ripard, Chen-Yu Tsai,
	Jernej Skrabec, linux-crypto, linux-arm-kernel, kernel-janitors,
	linux-kernel

Le Thu, Apr 01, 2021 at 04:18:27PM +0100, Colin King a écrit :
> From: Colin Ian King <colin.king@canonical.com>
> 
> It appears there are several failure return paths that don't seem
> to be free'ing pad. Fix these.
> 
> Addresses-Coverity: ("Resource leak")
> Fixes: d9b45418a917 ("crypto: sun8i-ss - support hash algorithms")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---

Hello

Acked-by: Corentin Labbe <clabbe.montjoie@gmail.com>
Tested-by: Corentin Labbe <clabbe.montjoie@gmail.com>
Tested-on: sun8i-a83t-bananapi-m3

Thanks

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH][next] crypto: sun8i-ss: Fix memory leak of pad
  2021-04-01 15:18 [PATCH][next] crypto: sun8i-ss: Fix memory leak of pad Colin King
  2021-04-02 11:18 ` Corentin Labbe
@ 2021-04-09  7:54 ` Herbert Xu
  1 sibling, 0 replies; 3+ messages in thread
From: Herbert Xu @ 2021-04-09  7:54 UTC (permalink / raw)
  To: Colin King
  Cc: Corentin Labbe, David S . Miller, Maxime Ripard, Chen-Yu Tsai,
	Jernej Skrabec, linux-crypto, linux-arm-kernel, kernel-janitors,
	linux-kernel

On Thu, Apr 01, 2021 at 04:18:27PM +0100, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
> 
> It appears there are several failure return paths that don't seem
> to be free'ing pad. Fix these.
> 
> Addresses-Coverity: ("Resource leak")
> Fixes: d9b45418a917 ("crypto: sun8i-ss - support hash algorithms")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>  drivers/crypto/allwinner/sun8i-ss/sun8i-ss-hash.c | 7 ++++---
>  1 file changed, 4 insertions(+), 3 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

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-04-09  7:57 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-01 15:18 [PATCH][next] crypto: sun8i-ss: Fix memory leak of pad Colin King
2021-04-02 11:18 ` Corentin Labbe
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).