diff options
| author | Kees Cook <kees@kernel.org> | 2026-02-20 23:49:23 -0800 |
|---|---|---|
| committer | Kees Cook <kees@kernel.org> | 2026-02-21 01:02:28 -0800 |
| commit | 69050f8d6d075dc01af7a5f2f550a8067510366f (patch) | |
| tree | bb265f94d9dfa7876c06a5d9f88673d496a15341 /fs/affs | |
| parent | d39a1d7486d98668dd34aaa6732aad7977c45f5a (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/affs')
| -rw-r--r-- | fs/affs/dir.c | 2 | ||||
| -rw-r--r-- | fs/affs/super.c | 4 |
2 files changed, 3 insertions, 3 deletions
diff --git a/fs/affs/dir.c b/fs/affs/dir.c index fe18caaf4d65..39b6ddc4e4b1 100644 --- a/fs/affs/dir.c +++ b/fs/affs/dir.c @@ -36,7 +36,7 @@ static int affs_dir_open(struct inode *inode, struct file *file) { struct affs_dir_data *data; - data = kzalloc(sizeof(struct affs_dir_data), GFP_KERNEL); + data = kzalloc_obj(struct affs_dir_data, GFP_KERNEL); if (!data) return -ENOMEM; file->private_data = data; diff --git a/fs/affs/super.c b/fs/affs/super.c index 44f8aa883100..1a2f72fea1ab 100644 --- a/fs/affs/super.c +++ b/fs/affs/super.c @@ -327,7 +327,7 @@ static int affs_fill_super(struct super_block *sb, struct fs_context *fc) sb->s_time_min = sys_tz.tz_minuteswest * 60 + AFFS_EPOCH_DELTA; sb->s_time_max = 86400LL * U32_MAX + 86400 + sb->s_time_min; - sbi = kzalloc(sizeof(struct affs_sb_info), GFP_KERNEL); + sbi = kzalloc_obj(struct affs_sb_info, GFP_KERNEL); if (!sbi) return -ENOMEM; @@ -615,7 +615,7 @@ static int affs_init_fs_context(struct fs_context *fc) { struct affs_context *ctx; - ctx = kzalloc(sizeof(struct affs_context), GFP_KERNEL); + ctx = kzalloc_obj(struct affs_context, GFP_KERNEL); if (!ctx) return -ENOMEM; |
