diff mbox series

[4/7] keys: Add a key_ref_get() wrapper

Message ID 20240821123616.60401-5-dhowells@redhat.com (mailing list archive)
State New
Headers show
Series keys: Add tracepoints | expand

Commit Message

David Howells Aug. 21, 2024, 12:36 p.m. UTC
Add a key_ref_get() wrapper function to go with key_ref_put() and use it
for the place that needs it.

Signed-off-by: David Howells <dhowells@redhat.com>
cc: Jarkko Sakkinen <jarkko@kernel.org>
cc: keyrings@vger.kernel.org
cc: linux-security-module@vger.kernel.org
---
 include/linux/key.h     | 5 +++++
 security/keys/keyring.c | 2 +-
 2 files changed, 6 insertions(+), 1 deletion(-)

Comments

Jarkko Sakkinen Aug. 27, 2024, 6:23 p.m. UTC | #1
On Wed Aug 21, 2024 at 3:36 PM EEST, David Howells wrote:
> Add a key_ref_get() wrapper function to go with key_ref_put() and use it
> for the place that needs it.
>
> Signed-off-by: David Howells <dhowells@redhat.com>
> cc: Jarkko Sakkinen <jarkko@kernel.org>
> cc: keyrings@vger.kernel.org
> cc: linux-security-module@vger.kernel.org
> ---
>  include/linux/key.h     | 5 +++++
>  security/keys/keyring.c | 2 +-
>  2 files changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/include/linux/key.h b/include/linux/key.h
> index 08062b4f807c..50a19e5f9e45 100644
> --- a/include/linux/key.h
> +++ b/include/linux/key.h
> @@ -315,6 +315,11 @@ static inline void key_ref_put(key_ref_t key_ref)
>  	key_put(key_ref_to_ptr(key_ref));
>  }
>  
> +static inline void key_ref_get(key_ref_t key_ref)
> +{
> +	key_get(key_ref_to_ptr(key_ref));
> +}
> +
>  extern struct key *request_key_tag(struct key_type *type,
>  				   const char *description,
>  				   struct key_tag *domain_tag,
> diff --git a/security/keys/keyring.c b/security/keys/keyring.c
> index 0eed018448cb..7f02b913c560 100644
> --- a/security/keys/keyring.c
> +++ b/security/keys/keyring.c
> @@ -920,7 +920,7 @@ key_ref_t keyring_search_rcu(key_ref_t keyring_ref,
>  
>  	ctx->now = ktime_get_real_seconds();
>  	if (search_nested_keyrings(keyring, ctx))
> -		__key_get(key_ref_to_ptr(ctx->result));
> +		key_ref_get(ctx->result);
>  	return ctx->result;
>  }
>  

Reviewed-by: Jarkko Sakkinen <jarkko@kernel.org>

BR, Jarkko
diff mbox series

Patch

diff --git a/include/linux/key.h b/include/linux/key.h
index 08062b4f807c..50a19e5f9e45 100644
--- a/include/linux/key.h
+++ b/include/linux/key.h
@@ -315,6 +315,11 @@  static inline void key_ref_put(key_ref_t key_ref)
 	key_put(key_ref_to_ptr(key_ref));
 }
 
+static inline void key_ref_get(key_ref_t key_ref)
+{
+	key_get(key_ref_to_ptr(key_ref));
+}
+
 extern struct key *request_key_tag(struct key_type *type,
 				   const char *description,
 				   struct key_tag *domain_tag,
diff --git a/security/keys/keyring.c b/security/keys/keyring.c
index 0eed018448cb..7f02b913c560 100644
--- a/security/keys/keyring.c
+++ b/security/keys/keyring.c
@@ -920,7 +920,7 @@  key_ref_t keyring_search_rcu(key_ref_t keyring_ref,
 
 	ctx->now = ktime_get_real_seconds();
 	if (search_nested_keyrings(keyring, ctx))
-		__key_get(key_ref_to_ptr(ctx->result));
+		key_ref_get(ctx->result);
 	return ctx->result;
 }