Commit dbb018cd authored by Darren Jenkins's avatar Darren Jenkins Committed by Herbert Xu

crypto: tcrypt - Fix memory leak in test_cipher

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: default avatarDarren Jenkins <darrenrjenkins@gmailcom>
Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
parent 7b51ba38
...@@ -586,12 +586,6 @@ static void test_cipher(char *algo, int enc, ...@@ -586,12 +586,6 @@ static void test_cipher(char *algo, int enc,
j = 0; j = 0;
for (i = 0; i < tcount; i++) { 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) if (template[i].iv)
memcpy(iv, template[i].iv, MAX_IVLEN); memcpy(iv, template[i].iv, MAX_IVLEN);
else else
...@@ -613,11 +607,9 @@ static void test_cipher(char *algo, int enc, ...@@ -613,11 +607,9 @@ static void test_cipher(char *algo, int enc,
printk("setkey() failed flags=%x\n", printk("setkey() failed flags=%x\n",
crypto_ablkcipher_get_flags(tfm)); crypto_ablkcipher_get_flags(tfm));
if (!template[i].fail) { if (!template[i].fail)
kfree(data);
goto out; goto out;
} }
}
temp = 0; temp = 0;
sg_init_table(sg, template[i].np); sg_init_table(sg, template[i].np);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment