2008-07-08 07:11:35

by Darren Jenkins

[permalink] [raw]
Subject: [PATCH] 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 <[email protected]>

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);


2008-07-08 08:22:57

by Herbert Xu

[permalink] [raw]
Subject: Re: [PATCH] crypto/tcrypt.c fix resource leak

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 <[email protected]>

Patch applied. Thanks!
--
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