Skip to contentSkip to conversation

crypto/tcrypt.c fix resource leak

PATCH In review Darren Jenkins\ 2 participants 2 messages Jul 7, 2008 – Jul 8, 2008

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 crypto/tcrypt.c fix resource leak

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>

crypto/tcrypt.c +1 -9
index 6beabc5..e47f6e0 100644
@@ -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;

--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

maintainer
#1 lore raw
Quoted 11 lines · Darren Jenkins

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.

Quoted 3 lines

Only compile tested.

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

Patch applied. Thanks!

Signature · 8 lines
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html