The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [PATCH] ecryptfs: use kasprintf in ecryptfs_crypto_api_algify_cipher_name
@ 2026-05-18  7:38 Thorsten Blum
  2026-06-02 22:37 ` Thorsten Blum
  0 siblings, 1 reply; 2+ messages in thread
From: Thorsten Blum @ 2026-05-18  7:38 UTC (permalink / raw)
  To: Tyler Hicks; +Cc: ecryptfs, linux-kernel, Thorsten Blum

Use kasprintf() to simplify ecryptfs_crypto_api_algify_cipher_name().

Use const char * for the read-only cipher name and chaining modifier
while at it.

Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
---
 fs/ecryptfs/crypto.c | 24 +++++++-----------------
 1 file changed, 7 insertions(+), 17 deletions(-)

diff --git a/fs/ecryptfs/crypto.c b/fs/ecryptfs/crypto.c
index 5ef67b2674ee..74b02b55e3f6 100644
--- a/fs/ecryptfs/crypto.c
+++ b/fs/ecryptfs/crypto.c
@@ -49,25 +49,15 @@ void ecryptfs_from_hex(char *dst, char *src, int dst_size)
 }
 
 static int ecryptfs_crypto_api_algify_cipher_name(char **algified_name,
-						  char *cipher_name,
-						  char *chaining_modifier)
+						  const char *cipher_name,
+						  const char *chaining_modifier)
 {
-	int cipher_name_len = strlen(cipher_name);
-	int chaining_modifier_len = strlen(chaining_modifier);
-	int algified_name_len;
-	int rc;
+	(*algified_name) = kasprintf(GFP_KERNEL, "%s(%s)", chaining_modifier,
+				     cipher_name);
+	if (!(*algified_name))
+		return -ENOMEM;
 
-	algified_name_len = (chaining_modifier_len + cipher_name_len + 3);
-	(*algified_name) = kmalloc(algified_name_len, GFP_KERNEL);
-	if (!(*algified_name)) {
-		rc = -ENOMEM;
-		goto out;
-	}
-	snprintf((*algified_name), algified_name_len, "%s(%s)",
-		 chaining_modifier, cipher_name);
-	rc = 0;
-out:
-	return rc;
+	return 0;
 }
 
 /**

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] ecryptfs: use kasprintf in ecryptfs_crypto_api_algify_cipher_name
  2026-05-18  7:38 [PATCH] ecryptfs: use kasprintf in ecryptfs_crypto_api_algify_cipher_name Thorsten Blum
@ 2026-06-02 22:37 ` Thorsten Blum
  0 siblings, 0 replies; 2+ messages in thread
From: Thorsten Blum @ 2026-06-02 22:37 UTC (permalink / raw)
  To: Tyler Hicks; +Cc: ecryptfs, linux-kernel

Gentle ping?

On Mon, May 18, 2026 at 09:38:45AM +0200, Thorsten Blum wrote:
> Use kasprintf() to simplify ecryptfs_crypto_api_algify_cipher_name().
> 
> Use const char * for the read-only cipher name and chaining modifier
> while at it.
> 
> Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
> ---
>  fs/ecryptfs/crypto.c | 24 +++++++-----------------
>  1 file changed, 7 insertions(+), 17 deletions(-)
> 
> diff --git a/fs/ecryptfs/crypto.c b/fs/ecryptfs/crypto.c
> index 5ef67b2674ee..74b02b55e3f6 100644
> --- a/fs/ecryptfs/crypto.c
> +++ b/fs/ecryptfs/crypto.c
> @@ -49,25 +49,15 @@ void ecryptfs_from_hex(char *dst, char *src, int dst_size)
>  }
>  
>  static int ecryptfs_crypto_api_algify_cipher_name(char **algified_name,
> -						  char *cipher_name,
> -						  char *chaining_modifier)
> +						  const char *cipher_name,
> +						  const char *chaining_modifier)
>  {
> -	int cipher_name_len = strlen(cipher_name);
> -	int chaining_modifier_len = strlen(chaining_modifier);
> -	int algified_name_len;
> -	int rc;
> +	(*algified_name) = kasprintf(GFP_KERNEL, "%s(%s)", chaining_modifier,
> +				     cipher_name);
> +	if (!(*algified_name))
> +		return -ENOMEM;
>  
> -	algified_name_len = (chaining_modifier_len + cipher_name_len + 3);
> -	(*algified_name) = kmalloc(algified_name_len, GFP_KERNEL);
> -	if (!(*algified_name)) {
> -		rc = -ENOMEM;
> -		goto out;
> -	}
> -	snprintf((*algified_name), algified_name_len, "%s(%s)",
> -		 chaining_modifier, cipher_name);
> -	rc = 0;
> -out:
> -	return rc;
> +	return 0;
>  }
>  
>  /**

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-06-02 22:37 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-18  7:38 [PATCH] ecryptfs: use kasprintf in ecryptfs_crypto_api_algify_cipher_name Thorsten Blum
2026-06-02 22:37 ` Thorsten Blum

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox