Skip to content

Commit

Permalink
trusted-keys: another free memory bugfix
Browse files Browse the repository at this point in the history
TSS_rawhmac() forgot to call va_end()/kfree() when data == NULL and
forgot to call va_end() when crypto_shash_update() < 0.
Fix these bugs by escaping from the loop using "break"
(rather than "return"/"goto") in order to make sure that
va_end()/kfree() are always called.

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>
  • Loading branch information
Tetsuo Handa authored and James Morris committed Jan 18, 2011
1 parent 40c1001 commit 35576ea
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions security/keys/trusted_defined.c
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,13 @@ static int TSS_rawhmac(unsigned char *digest, const unsigned char *key,
if (dlen == 0)
break;
data = va_arg(argp, unsigned char *);
if (data == NULL)
return -EINVAL;
if (data == NULL) {
ret = -EINVAL;
break;
}
ret = crypto_shash_update(&sdesc->shash, data, dlen);
if (ret < 0)
goto out;
break;
}
va_end(argp);
if (!ret)
Expand Down

0 comments on commit 35576ea

Please sign in to comment.