diff options
Diffstat (limited to 'kernel/security/keys/gc.c')
-rw-r--r-- | kernel/security/keys/gc.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/kernel/security/keys/gc.c b/kernel/security/keys/gc.c index c7952375a..addf06039 100644 --- a/kernel/security/keys/gc.c +++ b/kernel/security/keys/gc.c @@ -134,6 +134,12 @@ static noinline void key_gc_unused_keys(struct list_head *keys) kdebug("- %u", key->serial); key_check(key); + /* Throw away the key data if the key is instantiated */ + if (test_bit(KEY_FLAG_INSTANTIATED, &key->flags) && + !test_bit(KEY_FLAG_NEGATIVE, &key->flags) && + key->type->destroy) + key->type->destroy(key); + security_key_free(key); /* deal with the user's key tracking and quota */ @@ -148,10 +154,6 @@ static noinline void key_gc_unused_keys(struct list_head *keys) if (test_bit(KEY_FLAG_INSTANTIATED, &key->flags)) atomic_dec(&key->user->nikeys); - /* now throw away the key memory */ - if (key->type->destroy) - key->type->destroy(key); - key_user_put(key->user); kfree(key->description); |