diff options
author | Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp> | 2011-01-16 19:27:27 -0500 |
---|---|---|
committer | James Morris <jmorris@namei.org> | 2011-01-18 17:53:59 -0500 |
commit | 154a96bfcd53b8e5020718c64769e542c44788b9 (patch) | |
tree | 2fc7a4c8992fb4222a6fb47f22907a94da48eebd /security | |
parent | 0e7491f685cbc962f2ef977f7b5f8ed0b3100e88 (diff) |
trusted-keys: avoid scattring va_end()
We can avoid scattering va_end() within the
va_start();
for (;;) {
}
va_end();
loop, assuming that crypto_shash_init()/crypto_shash_update() return 0 on
success and negative value otherwise.
Make TSS_authhmac()/TSS_checkhmac1()/TSS_checkhmac2() similar to TSS_rawhmac()
by removing "va_end()/goto" from the loop.
Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Reviewed-by: Jesper Juhl <jj@chaosbits.net>
Acked-by: Mimi Zohar <zohar@us.ibm.com>
Acked-by: David Howells <dhowells@redhat.com>
Signed-off-by: James Morris <jmorris@namei.org>
Diffstat (limited to 'security')
-rw-r--r-- | security/keys/trusted_defined.c | 30 |
1 files changed, 13 insertions, 17 deletions
diff --git a/security/keys/trusted_defined.c b/security/keys/trusted_defined.c index f7d06776faf0..2836c6dc18a3 100644 --- a/security/keys/trusted_defined.c +++ b/security/keys/trusted_defined.c | |||
@@ -150,17 +150,15 @@ static int TSS_authhmac(unsigned char *digest, const unsigned char *key, | |||
150 | data = va_arg(argp, unsigned char *); | 150 | data = va_arg(argp, unsigned char *); |
151 | if (!data) { | 151 | if (!data) { |
152 | ret = -EINVAL; | 152 | ret = -EINVAL; |
153 | va_end(argp); | 153 | break; |
154 | goto out; | ||
155 | } | 154 | } |
156 | ret = crypto_shash_update(&sdesc->shash, data, dlen); | 155 | ret = crypto_shash_update(&sdesc->shash, data, dlen); |
157 | if (ret < 0) { | 156 | if (ret < 0) |
158 | va_end(argp); | 157 | break; |
159 | goto out; | ||
160 | } | ||
161 | } | 158 | } |
162 | va_end(argp); | 159 | va_end(argp); |
163 | ret = crypto_shash_final(&sdesc->shash, paramdigest); | 160 | if (!ret) |
161 | ret = crypto_shash_final(&sdesc->shash, paramdigest); | ||
164 | if (!ret) | 162 | if (!ret) |
165 | ret = TSS_rawhmac(digest, key, keylen, SHA1_DIGEST_SIZE, | 163 | ret = TSS_rawhmac(digest, key, keylen, SHA1_DIGEST_SIZE, |
166 | paramdigest, TPM_NONCE_SIZE, h1, | 164 | paramdigest, TPM_NONCE_SIZE, h1, |
@@ -229,13 +227,12 @@ static int TSS_checkhmac1(unsigned char *buffer, | |||
229 | break; | 227 | break; |
230 | dpos = va_arg(argp, unsigned int); | 228 | dpos = va_arg(argp, unsigned int); |
231 | ret = crypto_shash_update(&sdesc->shash, buffer + dpos, dlen); | 229 | ret = crypto_shash_update(&sdesc->shash, buffer + dpos, dlen); |
232 | if (ret < 0) { | 230 | if (ret < 0) |
233 | va_end(argp); | 231 | break; |
234 | goto out; | ||
235 | } | ||
236 | } | 232 | } |
237 | va_end(argp); | 233 | va_end(argp); |
238 | ret = crypto_shash_final(&sdesc->shash, paramdigest); | 234 | if (!ret) |
235 | ret = crypto_shash_final(&sdesc->shash, paramdigest); | ||
239 | if (ret < 0) | 236 | if (ret < 0) |
240 | goto out; | 237 | goto out; |
241 | 238 | ||
@@ -323,13 +320,12 @@ static int TSS_checkhmac2(unsigned char *buffer, | |||
323 | break; | 320 | break; |
324 | dpos = va_arg(argp, unsigned int); | 321 | dpos = va_arg(argp, unsigned int); |
325 | ret = crypto_shash_update(&sdesc->shash, buffer + dpos, dlen); | 322 | ret = crypto_shash_update(&sdesc->shash, buffer + dpos, dlen); |
326 | if (ret < 0) { | 323 | if (ret < 0) |
327 | va_end(argp); | 324 | break; |
328 | goto out; | ||
329 | } | ||
330 | } | 325 | } |
331 | va_end(argp); | 326 | va_end(argp); |
332 | ret = crypto_shash_final(&sdesc->shash, paramdigest); | 327 | if (!ret) |
328 | ret = crypto_shash_final(&sdesc->shash, paramdigest); | ||
333 | if (ret < 0) | 329 | if (ret < 0) |
334 | goto out; | 330 | goto out; |
335 | 331 | ||