Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 192442
b: refs/heads/master
c: 2b9e468
h: refs/heads/master
v: v3
  • Loading branch information
David Howells authored and James Morris committed May 6, 2010
1 parent 976baec commit 982756d
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 553d603c8fce8cf727eb26e4bf6b9549cd4623f1
refs/heads/master: 2b9e4688fad8867b6e918610f396af3ab9246898
24 changes: 22 additions & 2 deletions trunk/security/keys/request_key.c
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,7 @@ static int construct_alloc_key(struct key_type *type,
const struct cred *cred = current_cred();
struct key *key;
key_ref_t key_ref;
int ret;

kenter("%s,%s,,,", type->name, description);

Expand Down Expand Up @@ -337,14 +338,23 @@ static int construct_alloc_key(struct key_type *type,
kleave(" = 0 [%d]", key_serial(key));
return 0;

/* the key is now present - we tell the caller that we found it by
* returning -EINPROGRESS */
key_already_present:
mutex_unlock(&key_construction_mutex);
ret = 0;
if (dest_keyring) {
__key_link(dest_keyring, key_ref_to_ptr(key_ref));
ret = __key_link(dest_keyring, key_ref_to_ptr(key_ref));
up_write(&dest_keyring->sem);
}
mutex_unlock(&user->cons_lock);
key_put(key);
if (ret < 0) {
key_ref_put(key_ref);
*_key = NULL;
kleave(" = %d [link]", ret);
return ret;
}
*_key = key = key_ref_to_ptr(key_ref);
kleave(" = -EINPROGRESS [%d]", key_serial(key));
return -EINPROGRESS;
Expand Down Expand Up @@ -390,6 +400,10 @@ static struct key *construct_key_and_link(struct key_type *type,
kdebug("cons failed");
goto construction_failed;
}
} else if (ret == -EINPROGRESS) {
ret = 0;
} else {
key = ERR_PTR(ret);
}

key_put(dest_keyring);
Expand Down Expand Up @@ -422,6 +436,7 @@ struct key *request_key_and_link(struct key_type *type,
const struct cred *cred = current_cred();
struct key *key;
key_ref_t key_ref;
int ret;

kenter("%s,%s,%p,%zu,%p,%p,%lx",
type->name, description, callout_info, callout_len, aux,
Expand All @@ -435,8 +450,13 @@ struct key *request_key_and_link(struct key_type *type,
key = key_ref_to_ptr(key_ref);
if (dest_keyring) {
construct_get_dest_keyring(&dest_keyring);
key_link(dest_keyring, key);
ret = key_link(dest_keyring, key);
key_put(dest_keyring);
if (ret < 0) {
key_put(key);
key = ERR_PTR(ret);
goto error;
}
}
} else if (PTR_ERR(key_ref) != -EAGAIN) {
key = ERR_CAST(key_ref);
Expand Down

0 comments on commit 982756d

Please sign in to comment.