diff options
author | James Morris <james.l.morris@oracle.com> | 2017-07-25 10:44:18 +1000 |
---|---|---|
committer | James Morris <james.l.morris@oracle.com> | 2017-07-25 10:44:18 +1000 |
commit | 53a2ebaaabc1eb8458796fec3bc1e0e80746b642 (patch) | |
tree | 9d1f9227b49392cdd2edcc01057517da4f4b09c2 /security/keys/key.c | |
parent | 3cf29931453215536916d0c4da953fce1911ced3 (diff) | |
parent | 520eccdfe187591a51ea9ab4c1a024ae4d0f68d9 (diff) | |
download | talos-obmc-linux-53a2ebaaabc1eb8458796fec3bc1e0e80746b642.tar.gz talos-obmc-linux-53a2ebaaabc1eb8458796fec3bc1e0e80746b642.zip |
sync to Linus v4.13-rc2 for subsystem developers to work against
Diffstat (limited to 'security/keys/key.c')
-rw-r--r-- | security/keys/key.c | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/security/keys/key.c b/security/keys/key.c index 455c04d80bbb..83da68d98b40 100644 --- a/security/keys/key.c +++ b/security/keys/key.c @@ -660,14 +660,11 @@ not_found: goto error; found: - /* pretend it doesn't exist if it is awaiting deletion */ - if (refcount_read(&key->usage) == 0) - goto not_found; - - /* this races with key_put(), but that doesn't matter since key_put() - * doesn't actually change the key + /* A key is allowed to be looked up only if someone still owns a + * reference to it - otherwise it's awaiting the gc. */ - __key_get(key); + if (!refcount_inc_not_zero(&key->usage)) + goto not_found; error: spin_unlock(&key_serial_lock); @@ -966,12 +963,11 @@ int key_update(key_ref_t key_ref, const void *payload, size_t plen) /* the key must be writable */ ret = key_permission(key_ref, KEY_NEED_WRITE); if (ret < 0) - goto error; + return ret; /* attempt to update it if supported */ - ret = -EOPNOTSUPP; if (!key->type->update) - goto error; + return -EOPNOTSUPP; memset(&prep, 0, sizeof(prep)); prep.data = payload; |