aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/key.h
diff options
context:
space:
mode:
authorDavid Howells <dhowells@redhat.com>2013-09-24 05:35:16 -0400
committerDavid Howells <dhowells@redhat.com>2013-09-24 05:35:16 -0400
commitccc3e6d9c9aea07a0b60b2b0bfc5b05a704b66d5 (patch)
treed111175934b1454fa275fe056f8c6d320e504b01 /include/linux/key.h
parentd0a059cac6523b23ad7d743dec8783705aab1668 (diff)
KEYS: Define a __key_get() wrapper to use rather than atomic_inc()
Define a __key_get() wrapper to use rather than atomic_inc() on the key usage count as this makes it easier to hook in refcount error debugging. Signed-off-by: David Howells <dhowells@redhat.com>
Diffstat (limited to 'include/linux/key.h')
-rw-r--r--include/linux/key.h10
1 files changed, 7 insertions, 3 deletions
diff --git a/include/linux/key.h b/include/linux/key.h
index d573e820a23d..ef596c7af585 100644
--- a/include/linux/key.h
+++ b/include/linux/key.h
@@ -219,13 +219,17 @@ extern void key_revoke(struct key *key);
219extern void key_invalidate(struct key *key); 219extern void key_invalidate(struct key *key);
220extern void key_put(struct key *key); 220extern void key_put(struct key *key);
221 221
222static inline struct key *key_get(struct key *key) 222static inline struct key *__key_get(struct key *key)
223{ 223{
224 if (key) 224 atomic_inc(&key->usage);
225 atomic_inc(&key->usage);
226 return key; 225 return key;
227} 226}
228 227
228static inline struct key *key_get(struct key *key)
229{
230 return key ? __key_get(key) : key;
231}
232
229static inline void key_ref_put(key_ref_t key_ref) 233static inline void key_ref_put(key_ref_t key_ref)
230{ 234{
231 key_put(key_ref_to_ptr(key_ref)); 235 key_put(key_ref_to_ptr(key_ref));