diff options
Diffstat (limited to 'security/keys')
-rw-r--r-- | security/keys/request_key.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/security/keys/request_key.c b/security/keys/request_key.c index 03fe63ed55bd..9ac7bfd3bbdd 100644 --- a/security/keys/request_key.c +++ b/security/keys/request_key.c @@ -336,8 +336,10 @@ static int construct_alloc_key(struct key_type *type, key_already_present: mutex_unlock(&key_construction_mutex); - if (dest_keyring) + if (dest_keyring) { + __key_link(dest_keyring, key_ref_to_ptr(key_ref)); up_write(&dest_keyring->sem); + } mutex_unlock(&user->cons_lock); key_put(key); *_key = key = key_ref_to_ptr(key_ref); @@ -428,6 +430,11 @@ struct key *request_key_and_link(struct key_type *type, if (!IS_ERR(key_ref)) { key = key_ref_to_ptr(key_ref); + if (dest_keyring) { + construct_get_dest_keyring(&dest_keyring); + key_link(dest_keyring, key); + key_put(dest_keyring); + } } else if (PTR_ERR(key_ref) != -EAGAIN) { key = ERR_CAST(key_ref); } else { |