aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--security/keys/request_key.c9
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,
336 336
337key_already_present: 337key_already_present:
338 mutex_unlock(&key_construction_mutex); 338 mutex_unlock(&key_construction_mutex);
339 if (dest_keyring) 339 if (dest_keyring) {
340 __key_link(dest_keyring, key_ref_to_ptr(key_ref));
340 up_write(&dest_keyring->sem); 341 up_write(&dest_keyring->sem);
342 }
341 mutex_unlock(&user->cons_lock); 343 mutex_unlock(&user->cons_lock);
342 key_put(key); 344 key_put(key);
343 *_key = key = key_ref_to_ptr(key_ref); 345 *_key = key = key_ref_to_ptr(key_ref);
@@ -428,6 +430,11 @@ struct key *request_key_and_link(struct key_type *type,
428 430
429 if (!IS_ERR(key_ref)) { 431 if (!IS_ERR(key_ref)) {
430 key = key_ref_to_ptr(key_ref); 432 key = key_ref_to_ptr(key_ref);
433 if (dest_keyring) {
434 construct_get_dest_keyring(&dest_keyring);
435 key_link(dest_keyring, key);
436 key_put(dest_keyring);
437 }
431 } else if (PTR_ERR(key_ref) != -EAGAIN) { 438 } else if (PTR_ERR(key_ref) != -EAGAIN) {
432 key = ERR_CAST(key_ref); 439 key = ERR_CAST(key_ref);
433 } else { 440 } else {