summaryrefslogtreecommitdiff
path: root/fs/ntfs3/fslog.c
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/ntfs3/fslog.c
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/ntfs3/fslog.c')
-rw-r--r--fs/ntfs3/fslog.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/fs/ntfs3/fslog.c b/fs/ntfs3/fslog.c
index 10863c83c315..272e45276143 100644
--- a/fs/ntfs3/fslog.c
+++ b/fs/ntfs3/fslog.c
@@ -2473,7 +2473,7 @@ static int read_log_rec_lcb(struct ntfs_log *log, u64 lsn, u32 ctx_mode,
if (!verify_client_lsn(log, cr, lsn))
return -EINVAL;
- lcb = kzalloc(sizeof(struct lcb), GFP_NOFS);
+ lcb = kzalloc_obj(struct lcb, GFP_NOFS);
if (!lcb)
return -ENOMEM;
lcb->client = log->client_id;
@@ -3117,8 +3117,7 @@ static int do_action(struct ntfs_log *log, struct OPEN_ATTR_ENRTY *oe,
/* Read from disk. */
err = mi_get(sbi, rno, &mi);
if (err && op == InitializeFileRecordSegment) {
- mi = kzalloc(sizeof(struct mft_inode),
- GFP_NOFS);
+ mi = kzalloc_obj(struct mft_inode, GFP_NOFS);
if (!mi)
return -ENOMEM;
err = mi_format_new(mi, sbi, rno, 0, false);
@@ -3779,7 +3778,7 @@ int log_replay(struct ntfs_inode *ni, bool *initialized)
u16 t16;
u32 t32;
- log = kzalloc(sizeof(struct ntfs_log), GFP_NOFS);
+ log = kzalloc_obj(struct ntfs_log, GFP_NOFS);
if (!log)
return -ENOMEM;
@@ -4725,7 +4724,7 @@ next_open_attribute:
goto next_dirty_page;
}
- oa = kzalloc(sizeof(struct OpenAttr), GFP_NOFS);
+ oa = kzalloc_obj(struct OpenAttr, GFP_NOFS);
if (!oa) {
err = -ENOMEM;
goto out;