Message ID | 1445886329-12035-2-git-send-email-luis.henriques@canonical.com |
---|---|
State | New |
Headers | show |
diff --git a/security/keys/gc.c b/security/keys/gc.c index 38676fac7943..4a780333c22c 100644 --- a/security/keys/gc.c +++ b/security/keys/gc.c @@ -143,8 +143,10 @@ static noinline void key_gc_unused_keys(struct list_head *keys) kdebug("- %u", key->serial); key_check(key); - /* Throw away the key data */ - if (key->type->destroy) + /* 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);