summaryrefslogtreecommitdiff
path: root/fs/exfat
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/exfat
parentd39a1d7486d98668dd34aaa6732aad7977c45f5a (diff)
downloadlinux-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/exfat')
-rw-r--r--fs/exfat/balloc.c4
-rw-r--r--fs/exfat/dir.c2
-rw-r--r--fs/exfat/super.c2
3 files changed, 4 insertions, 4 deletions
diff --git a/fs/exfat/balloc.c b/fs/exfat/balloc.c
index 5429041c7eaf..8dd9e39f8ccf 100644
--- a/fs/exfat/balloc.c
+++ b/fs/exfat/balloc.c
@@ -96,8 +96,8 @@ static int exfat_allocate_bitmap(struct super_block *sb,
}
sbi->map_sectors = ((need_map_size - 1) >>
(sb->s_blocksize_bits)) + 1;
- sbi->vol_amap = kvmalloc_array(sbi->map_sectors,
- sizeof(struct buffer_head *), GFP_KERNEL);
+ sbi->vol_amap = kvmalloc_objs(struct buffer_head *, sbi->map_sectors,
+ GFP_KERNEL);
if (!sbi->vol_amap)
return -ENOMEM;
diff --git a/fs/exfat/dir.c b/fs/exfat/dir.c
index 2dbf335eafef..3a4853693d8b 100644
--- a/fs/exfat/dir.c
+++ b/fs/exfat/dir.c
@@ -802,7 +802,7 @@ static int __exfat_get_dentry_set(struct exfat_entry_set_cache *es,
num_bh = EXFAT_B_TO_BLK_ROUND_UP(off + num_entries * DENTRY_SIZE, sb);
if (num_bh > ARRAY_SIZE(es->__bh)) {
- es->bh = kmalloc_array(num_bh, sizeof(*es->bh), GFP_NOFS);
+ es->bh = kmalloc_objs(*es->bh, num_bh, GFP_NOFS);
if (!es->bh) {
brelse(bh);
return -ENOMEM;
diff --git a/fs/exfat/super.c b/fs/exfat/super.c
index 10e872a99663..42a232394afb 100644
--- a/fs/exfat/super.c
+++ b/fs/exfat/super.c
@@ -815,7 +815,7 @@ static int exfat_init_fs_context(struct fs_context *fc)
{
struct exfat_sb_info *sbi;
- sbi = kzalloc(sizeof(struct exfat_sb_info), GFP_KERNEL);
+ sbi = kzalloc_obj(struct exfat_sb_info, GFP_KERNEL);
if (!sbi)
return -ENOMEM;