* [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
2026-06-04 19:53 ` Tyler Hicks
0 siblings, 2 replies; 3+ 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] 3+ 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
2026-06-04 19:53 ` Tyler Hicks
1 sibling, 0 replies; 3+ 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] 3+ 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
@ 2026-06-04 19:53 ` Tyler Hicks
1 sibling, 0 replies; 3+ messages in thread
From: Tyler Hicks @ 2026-06-04 19:53 UTC (permalink / raw)
To: Thorsten Blum; +Cc: ecryptfs, linux-kernel
On Mon, 18 May 2026 09:38:45 +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.
Thank you! This has been applied to the next branch of the tyhicks/ecryptfs.git tree.
You can find a direct link below but please be aware that the commit hash is
unstable and, therefore, the URL may not be valid in the future.
[1/1] ecryptfs: use kasprintf in ecryptfs_crypto_api_algify_cipher_name
https://git.kernel.org/tyhicks/ecryptfs/c/95ce5ffd54cf66098f91892f98606c3bd33846fe
Tyler
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-06-04 19:53 UTC | newest]
Thread overview: 3+ 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
2026-06-04 19:53 ` Tyler Hicks
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.