Dead code in crypto/tcrypt.c
hi,
the following commit added some code in test_hash_cycles() which coverity flags as dead code.
http://www.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commitdiff;h=e9d41164e2fdd897fe4520c2079ea0000f6e0ec3
The culprit are the following lines:
for (i = 0; i < 4; i++) {
- crypto_digest_init(tfm);
+ ret = crypto_hash_init(desc);
+ if (ret)
+ goto out;
for (pcount = 0; pcount < blen; pcount += plen) {
sg_set_buf(sg, p + pcount, plen);
- crypto_digest_update(tfm, sg, 1);
+ ret = crypto_hash_update(desc, sg, plen);
+ if (ret)
+ goto out;
}
- crypto_digest_final(tfm, out);
+ crypto_hash_final(desc, out);
+ if (ret)
+ goto out;
}We check ret before the for loop, and inside it, and there is no way it can change in between. Are we missing to assign the return value of crypto_hash_final() to ret?
Greetings, Eric
Herbert Xu
maintainerQuoted 3 lines · Eric Sesterhenn
the following commit added some code in
test_hash_cycles()which coverity flags as dead code.
http://www.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commitdiff;h=e9d41164e2fdd897fe4520c2079ea0000f6e0ec3
Thanks for spotting this. I've put the following patch into the tree.
Signature · 5 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
--crypto/tcrypt.c +1 -1
@@ -646,7 +646,7 @@ static int test_hash_cycles(struct hash_if (ret) goto out; } -crypto_hash_final (desc, out); + ret =crypto_hash_final (desc, out);if (ret) goto out; }