Commit dbb018cd8a0fd073eaabf9de5a93f62d98bd7723

Authored by Darren Jenkins
Committed by Herbert Xu
1 parent 7b51ba38d9

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: Darren Jenkins <darrenrjenkins@gmailcom>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

Showing 1 changed file with 1 additions and 9 deletions Side-by-side Diff

... ... @@ -586,12 +586,6 @@
586 586 j = 0;
587 587 for (i = 0; i < tcount; i++) {
588 588  
589   - data = kzalloc(template[i].ilen, GFP_KERNEL);
590   - if (!data)
591   - continue;
592   -
593   - memcpy(data, template[i].input, template[i].ilen);
594   -
595 589 if (template[i].iv)
596 590 memcpy(iv, template[i].iv, MAX_IVLEN);
597 591 else
598 592  
... ... @@ -613,10 +607,8 @@
613 607 printk("setkey() failed flags=%x\n",
614 608 crypto_ablkcipher_get_flags(tfm));
615 609  
616   - if (!template[i].fail) {
617   - kfree(data);
  610 + if (!template[i].fail)
618 611 goto out;
619   - }
620 612 }
621 613  
622 614 temp = 0;