mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] crypto/tcrypt.c fix resource leak
@ 2008-07-07 19:24 Darren Jenkins\
  2008-07-08  8:22 ` Herbert Xu
  0 siblings, 1 reply; 2+ messages in thread
From: Darren Jenkins\ @ 2008-07-07 19:24 UTC (permalink / raw)
  To: kernel Janitors, LKML, herbert, davem, linux-crypto, jmorris, jef

G'day people,

Coverity CID: 2306 & 2307 RESOURCE_LEAK

In the second for loop in test_cipher(), data is allocated space with
kzalloc() and is only ever freed in an error case.
Looking at this loop, data is written to this memory but nothing seems
to read from it. 
So here is a patch removing the allocation, I think this is the right
fix.

Only compile tested.

Signed-off-by: Darren Jenkins <darrenrjenkins@gmailcom>

diff --git a/crypto/tcrypt.c b/crypto/tcrypt.c
index 6beabc5..e47f6e0 100644
--- a/crypto/tcrypt.c
+++ b/crypto/tcrypt.c
@@ -586,12 +586,6 @@ static void test_cipher(char *algo, int enc,
 	j = 0;
 	for (i = 0; i < tcount; i++) {
 
-		data = kzalloc(template[i].ilen, GFP_KERNEL);
-		if (!data)
-			continue;
-
-		memcpy(data, template[i].input, template[i].ilen);
-
 		if (template[i].iv)
 			memcpy(iv, template[i].iv, MAX_IVLEN);
 		else
@@ -613,10 +607,8 @@ static void test_cipher(char *algo, int enc,
 				printk("setkey() failed flags=%x\n",
 						crypto_ablkcipher_get_flags(tfm));
 
-				if (!template[i].fail) {
-					kfree(data);
+				if (!template[i].fail)
 					goto out;
-				}
 			}
 
 			temp = 0;



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

* Re: [PATCH] crypto/tcrypt.c fix resource leak
  2008-07-07 19:24 [PATCH] crypto/tcrypt.c fix resource leak Darren Jenkins\
@ 2008-07-08  8:22 ` Herbert Xu
  0 siblings, 0 replies; 2+ messages in thread
From: Herbert Xu @ 2008-07-08  8:22 UTC (permalink / raw)
  To: Darren Jenkins"
  Cc: kernel Janitors, LKML, davem, linux-crypto, jmorris, jef

On Tue, Jul 08, 2008 at 05:24:14AM +1000, Darren Jenkins" wrote:
> G'day people,
> 
> Coverity CID: 2306 & 2307 RESOURCE_LEAK
> 
> In the second for loop in test_cipher(), data is allocated space with
> kzalloc() and is only ever freed in an error case.
> Looking at this loop, data is written to this memory but nothing seems
> to read from it. 
> So here is a patch removing the allocation, I think this is the right
> fix.
> 
> Only compile tested.
> 
> Signed-off-by: Darren Jenkins <darrenrjenkins@gmailcom>

Patch applied.  Thanks!
-- 
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <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:[~2008-07-08  8:23 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-07-07 19:24 [PATCH] crypto/tcrypt.c fix resource leak Darren Jenkins\
2008-07-08  8:22 ` Herbert Xu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®