summaryrefslogtreecommitdiff
path: root/fs/hpfs
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/hpfs
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/hpfs')
-rw-r--r--fs/hpfs/dnode.c2
-rw-r--r--fs/hpfs/super.c4
2 files changed, 3 insertions, 3 deletions
diff --git a/fs/hpfs/dnode.c b/fs/hpfs/dnode.c
index 4ada525c5c43..dde764ebe246 100644
--- a/fs/hpfs/dnode.c
+++ b/fs/hpfs/dnode.c
@@ -33,7 +33,7 @@ int hpfs_add_pos(struct inode *inode, loff_t *pos)
if (hpfs_inode->i_rddir_off[i] == pos)
return 0;
if (!(i&0x0f)) {
- ppos = kmalloc_array(i + 0x11, sizeof(loff_t *), GFP_NOFS);
+ ppos = kmalloc_objs(loff_t *, i + 0x11, GFP_NOFS);
if (!ppos) {
pr_err("out of memory for position list\n");
return -ENOMEM;
diff --git a/fs/hpfs/super.c b/fs/hpfs/super.c
index 371aa6de8075..0f17b7710ae5 100644
--- a/fs/hpfs/super.c
+++ b/fs/hpfs/super.c
@@ -513,7 +513,7 @@ static int hpfs_fill_super(struct super_block *s, struct fs_context *fc)
struct hpfs_dirent *de = NULL;
struct quad_buffer_head qbh;
- sbi = kzalloc(sizeof(*sbi), GFP_KERNEL);
+ sbi = kzalloc_obj(*sbi, GFP_KERNEL);
if (!sbi) {
return -ENOMEM;
}
@@ -715,7 +715,7 @@ static int hpfs_init_fs_context(struct fs_context *fc)
{
struct hpfs_fc_context *ctx;
- ctx = kzalloc(sizeof(struct hpfs_fc_context), GFP_KERNEL);
+ ctx = kzalloc_obj(struct hpfs_fc_context, GFP_KERNEL);
if (!ctx)
return -ENOMEM;