summaryrefslogtreecommitdiff
path: root/fs/ecryptfs
diff options
context:
space:
mode:
authorKees Cook <kees@kernel.org>2026-02-20 23:49:23 -0800
committerKees Cook <kees@kernel.org>2026-02-21 01:02:28 -0800
commit69050f8d6d075dc01af7a5f2f550a8067510366f (patch)
treebb265f94d9dfa7876c06a5d9f88673d496a15341 /fs/ecryptfs
parentd39a1d7486d98668dd34aaa6732aad7977c45f5a (diff)
treewide: Replace kmalloc with kmalloc_obj for non-scalar types
This is the result of running the Coccinelle script from scripts/coccinelle/api/kmalloc_objs.cocci. The script is designed to avoid scalar types (which need careful case-by-case checking), and instead replace kmalloc-family calls that allocate struct or union object instances: Single allocations: kmalloc(sizeof(TYPE), ...) are replaced with: kmalloc_obj(TYPE, ...) Array allocations: kmalloc_array(COUNT, sizeof(TYPE), ...) are replaced with: kmalloc_objs(TYPE, COUNT, ...) Flex array allocations: kmalloc(struct_size(PTR, FAM, COUNT), ...) are replaced with: kmalloc_flex(*PTR, FAM, COUNT, ...) (where TYPE may also be *VAR) The resulting allocations no longer return "void *", instead returning "TYPE *". Signed-off-by: Kees Cook <kees@kernel.org>
Diffstat (limited to 'fs/ecryptfs')
-rw-r--r--fs/ecryptfs/crypto.c2
-rw-r--r--fs/ecryptfs/keystore.c4
-rw-r--r--fs/ecryptfs/main.c2
-rw-r--r--fs/ecryptfs/messaging.c2
4 files changed, 5 insertions, 5 deletions
diff --git a/fs/ecryptfs/crypto.c b/fs/ecryptfs/crypto.c
index 5459f18b3cca..6ada136f3f3f 100644
--- a/fs/ecryptfs/crypto.c
+++ b/fs/ecryptfs/crypto.c
@@ -1793,7 +1793,7 @@ int ecryptfs_encrypt_and_encode_filename(
& ECRYPTFS_GLOBAL_ENCRYPT_FILENAMES)) {
struct ecryptfs_filename *filename;
- filename = kzalloc(sizeof(*filename), GFP_KERNEL);
+ filename = kzalloc_obj(*filename, GFP_KERNEL);
if (!filename) {
rc = -ENOMEM;
goto out;
diff --git a/fs/ecryptfs/keystore.c b/fs/ecryptfs/keystore.c
index a41c82d610a7..04b6d296a3fa 100644
--- a/fs/ecryptfs/keystore.c
+++ b/fs/ecryptfs/keystore.c
@@ -623,7 +623,7 @@ ecryptfs_write_tag_70_packet(char *dest, size_t *remaining_bytes,
struct key *auth_tok_key = NULL;
int rc = 0;
- s = kzalloc(sizeof(*s), GFP_KERNEL);
+ s = kzalloc_obj(*s, GFP_KERNEL);
if (!s)
return -ENOMEM;
@@ -860,7 +860,7 @@ ecryptfs_parse_tag_70_packet(char **filename, size_t *filename_size,
(*packet_size) = 0;
(*filename_size) = 0;
(*filename) = NULL;
- s = kzalloc(sizeof(*s), GFP_KERNEL);
+ s = kzalloc_obj(*s, GFP_KERNEL);
if (!s)
return -ENOMEM;
diff --git a/fs/ecryptfs/main.c b/fs/ecryptfs/main.c
index 7d51e6b60f53..dcfa607fbf15 100644
--- a/fs/ecryptfs/main.c
+++ b/fs/ecryptfs/main.c
@@ -610,7 +610,7 @@ static int ecryptfs_init_fs_context(struct fs_context *fc)
struct ecryptfs_fs_context *ctx;
struct ecryptfs_sb_info *sbi = NULL;
- ctx = kzalloc(sizeof(struct ecryptfs_fs_context), GFP_KERNEL);
+ ctx = kzalloc_obj(struct ecryptfs_fs_context, GFP_KERNEL);
if (!ctx)
return -ENOMEM;
sbi = kmem_cache_zalloc(ecryptfs_sb_info_cache, GFP_KERNEL);
diff --git a/fs/ecryptfs/messaging.c b/fs/ecryptfs/messaging.c
index 6318f3500e5c..6cf3052e9370 100644
--- a/fs/ecryptfs/messaging.c
+++ b/fs/ecryptfs/messaging.c
@@ -131,7 +131,7 @@ ecryptfs_spawn_daemon(struct ecryptfs_daemon **daemon, struct file *file)
{
int rc = 0;
- (*daemon) = kzalloc(sizeof(**daemon), GFP_KERNEL);
+ (*daemon) = kzalloc_obj(**daemon, GFP_KERNEL);
if (!(*daemon)) {
rc = -ENOMEM;
goto out;