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/fuse/dax.c | |
| parent | d39a1d7486d98668dd34aaa6732aad7977c45f5a (diff) | |
| download | linux-next-69050f8d6d075dc01af7a5f2f550a8067510366f.tar.gz linux-next-69050f8d6d075dc01af7a5f2f550a8067510366f.zip | |
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/fuse/dax.c')
| -rw-r--r-- | fs/fuse/dax.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/fs/fuse/dax.c b/fs/fuse/dax.c index ac6d4c1064cc..7d11eac4f629 100644 --- a/fs/fuse/dax.c +++ b/fs/fuse/dax.c @@ -257,7 +257,7 @@ static int dmap_removemapping_list(struct inode *inode, unsigned int num, int ret, i = 0, nr_alloc; nr_alloc = min_t(unsigned int, num, FUSE_REMOVEMAPPING_MAX_ENTRY); - remove_one = kmalloc_array(nr_alloc, sizeof(*remove_one), GFP_NOFS); + remove_one = kmalloc_objs(*remove_one, nr_alloc, GFP_NOFS); if (!remove_one) return -ENOMEM; @@ -1219,7 +1219,7 @@ static int fuse_dax_mem_range_init(struct fuse_conn_dax *fcd) __func__, nr_pages, nr_ranges); for (i = 0; i < nr_ranges; i++) { - range = kzalloc(sizeof(struct fuse_dax_mapping), GFP_KERNEL); + range = kzalloc_obj(struct fuse_dax_mapping, GFP_KERNEL); ret = -ENOMEM; if (!range) goto out_err; @@ -1255,7 +1255,7 @@ int fuse_dax_conn_alloc(struct fuse_conn *fc, enum fuse_dax_mode dax_mode, if (!dax_dev) return 0; - fcd = kzalloc(sizeof(*fcd), GFP_KERNEL); + fcd = kzalloc_obj(*fcd, GFP_KERNEL); if (!fcd) return -ENOMEM; @@ -1277,7 +1277,7 @@ bool fuse_dax_inode_alloc(struct super_block *sb, struct fuse_inode *fi) fi->dax = NULL; if (fc->dax) { - fi->dax = kzalloc(sizeof(*fi->dax), GFP_KERNEL_ACCOUNT); + fi->dax = kzalloc_obj(*fi->dax, GFP_KERNEL_ACCOUNT); if (!fi->dax) return false; |
