trusted keys: Fix a memory leak in trusted_update().
authorJesper Juhl <jj@chaosbits.net>
Sun, 23 Jan 2011 21:40:42 +0000 (22:40 +0100)
committerJames Morris <jmorris@namei.org>
Sun, 23 Jan 2011 23:59:58 +0000 (10:59 +1100)
One failure path in security/keys/trusted.c::trusted_update() does
not free 'new_p' while the others do. This patch makes sure we also free
it in the remaining path (if datablob_parse() returns different from
Opt_update).

Signed-off-by: Jesper Juhl <jj@chaosbits.net>
Signed-off-by: James Morris <jmorris@namei.org>
security/keys/trusted.c

index 3066f56c7676afcb5ba438ca739ca069fbff0eac..83fc92e297cd2257a26c6cbeeaca2b0588deac4f 100644 (file)
@@ -1032,6 +1032,7 @@ static int trusted_update(struct key *key, const void *data, size_t datalen)
        ret = datablob_parse(datablob, new_p, new_o);
        if (ret != Opt_update) {
                ret = -EINVAL;
+               kfree(new_p);
                goto out;
        }
        /* copy old key values, and reseal with new pcrs */