summaryrefslogtreecommitdiff
path: root/fs
diff options
context:
space:
mode:
authorKees Cook <kees@kernel.org>2026-02-21 23:46:04 -0800
committerLinus Torvalds <torvalds@linux-foundation.org>2026-02-22 08:26:33 -0800
commit189f164e573e18d9f8876dbd3ad8fcbe11f93037 (patch)
tree733382723a15ea29b7c9f3dde3bcb281f0b3c287 /fs
parent32a92f8c89326985e05dce8b22d3f0aa07a3e1bd (diff)
Convert remaining multi-line kmalloc_obj/flex GFP_KERNEL uses
Conversion performed via this Coccinelle script: // SPDX-License-Identifier: GPL-2.0-only // Options: --include-headers-for-types --all-includes --include-headers --keep-comments virtual patch @gfp depends on patch && !(file in "tools") && !(file in "samples")@ identifier ALLOC = {kmalloc_obj,kmalloc_objs,kmalloc_flex, kzalloc_obj,kzalloc_objs,kzalloc_flex, kvmalloc_obj,kvmalloc_objs,kvmalloc_flex, kvzalloc_obj,kvzalloc_objs,kvzalloc_flex}; @@ ALLOC(... - , GFP_KERNEL ) $ make coccicheck MODE=patch COCCI=gfp.cocci Build and boot tested x86_64 with Fedora 42's GCC and Clang: Linux version 6.19.0+ (user@host) (gcc (GCC) 15.2.1 20260123 (Red Hat 15.2.1-7), GNU ld version 2.44-12.fc42) #1 SMP PREEMPT_DYNAMIC 1970-01-01 Linux version 6.19.0+ (user@host) (clang version 20.1.8 (Fedora 20.1.8-4.fc42), LLD 20.1.8) #1 SMP PREEMPT_DYNAMIC 1970-01-01 Signed-off-by: Kees Cook <kees@kernel.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs')
-rw-r--r--fs/afs/cmservice.c4
-rw-r--r--fs/afs/dir.c2
-rw-r--r--fs/afs/rotate.c3
-rw-r--r--fs/btrfs/fiemap.c2
-rw-r--r--fs/btrfs/scrub.c5
-rw-r--r--fs/btrfs/send.c6
-rw-r--r--fs/ceph/mds_client.c2
-rw-r--r--fs/erofs/zutil.c3
-rw-r--r--fs/ext4/mballoc.c3
-rw-r--r--fs/isofs/compress.c3
-rw-r--r--fs/jffs2/fs.c2
-rw-r--r--fs/nfs/callback_xdr.c5
-rw-r--r--fs/nfs/delegation.c3
-rw-r--r--fs/nfsd/export.c2
-rw-r--r--fs/nfsd/nfs4recover.c4
-rw-r--r--fs/nfsd/nfs4state.c4
-rw-r--r--fs/pstore/ram_core.c2
-rw-r--r--fs/smb/client/smbdirect.c2
-rw-r--r--fs/squashfs/file.c3
-rw-r--r--fs/udf/super.c2
20 files changed, 26 insertions, 36 deletions
diff --git a/fs/afs/cmservice.c b/fs/afs/cmservice.c
index 322a80b43f32..5540ae1cad59 100644
--- a/fs/afs/cmservice.c
+++ b/fs/afs/cmservice.c
@@ -229,7 +229,7 @@ static int afs_deliver_cb_callback(struct afs_call *call)
_debug("unmarshall FID array");
call->request = kzalloc_objs(struct afs_callback_break,
- call->count, GFP_KERNEL);
+ call->count);
if (!call->request)
return -ENOMEM;
@@ -589,7 +589,7 @@ static int afs_deliver_yfs_cb_callback(struct afs_call *call)
_debug("unmarshall FID array");
call->request = kzalloc_objs(struct afs_callback_break,
- call->count, GFP_KERNEL);
+ call->count);
if (!call->request)
return -ENOMEM;
diff --git a/fs/afs/dir.c b/fs/afs/dir.c
index e778a575e1ca..78caef3f1338 100644
--- a/fs/afs/dir.c
+++ b/fs/afs/dir.c
@@ -835,7 +835,7 @@ static struct inode *afs_do_lookup(struct inode *dir, struct dentry *dentry)
/* Need space for examining all the selected files */
if (op->nr_files > 2) {
op->more_files = kvzalloc_objs(struct afs_vnode_param,
- op->nr_files - 2, GFP_KERNEL);
+ op->nr_files - 2);
if (!op->more_files) {
afs_op_nomem(op);
goto out_op;
diff --git a/fs/afs/rotate.c b/fs/afs/rotate.c
index 69e80c5b6610..490b433e4395 100644
--- a/fs/afs/rotate.c
+++ b/fs/afs/rotate.c
@@ -47,8 +47,7 @@ static bool afs_start_fs_iteration(struct afs_operation *op,
read_unlock(&op->volume->servers_lock);
op->server_states = kzalloc_objs(op->server_states[0],
- op->server_list->nr_servers,
- GFP_KERNEL);
+ op->server_list->nr_servers);
if (!op->server_states) {
afs_op_nomem(op);
trace_afs_rotate(op, afs_rotate_trace_nomem, 0);
diff --git a/fs/btrfs/fiemap.c b/fs/btrfs/fiemap.c
index 2e113f81a2d8..27d361c7adc4 100644
--- a/fs/btrfs/fiemap.c
+++ b/fs/btrfs/fiemap.c
@@ -647,7 +647,7 @@ static int extent_fiemap(struct btrfs_inode *inode,
cache.entries_size = PAGE_SIZE / sizeof(struct btrfs_fiemap_entry);
cache.entries = kmalloc_objs(struct btrfs_fiemap_entry,
- cache.entries_size, GFP_KERNEL);
+ cache.entries_size);
backref_ctx = btrfs_alloc_backref_share_check_ctx();
path = btrfs_alloc_path();
if (!cache.entries || !backref_ctx || !path) {
diff --git a/fs/btrfs/scrub.c b/fs/btrfs/scrub.c
index 865dc30002cd..81022d912abb 100644
--- a/fs/btrfs/scrub.c
+++ b/fs/btrfs/scrub.c
@@ -374,7 +374,7 @@ static int init_scrub_stripe(struct btrfs_fs_info *fs_info,
goto error;
stripe->sectors = kzalloc_objs(struct scrub_sector_verification,
- stripe->nr_sectors, GFP_KERNEL);
+ stripe->nr_sectors);
if (!stripe->sectors)
goto error;
@@ -2474,8 +2474,7 @@ static noinline_for_stack int scrub_stripe(struct scrub_ctx *sctx,
ASSERT(sctx->raid56_data_stripes == NULL);
sctx->raid56_data_stripes = kzalloc_objs(struct scrub_stripe,
- nr_data_stripes(map),
- GFP_KERNEL);
+ nr_data_stripes(map));
if (!sctx->raid56_data_stripes) {
ret = -ENOMEM;
goto out;
diff --git a/fs/btrfs/send.c b/fs/btrfs/send.c
index 7b2ea38b62dd..904a2f57f86d 100644
--- a/fs/btrfs/send.c
+++ b/fs/btrfs/send.c
@@ -8098,8 +8098,7 @@ long btrfs_ioctl_send(struct btrfs_root *send_root, const struct btrfs_ioctl_sen
}
send_buf_num_pages = sctx->send_max_size >> PAGE_SHIFT;
sctx->send_buf_pages = kzalloc_objs(*sctx->send_buf_pages,
- send_buf_num_pages,
- GFP_KERNEL);
+ send_buf_num_pages);
if (!sctx->send_buf_pages) {
ret = -ENOMEM;
goto out;
@@ -8118,8 +8117,7 @@ long btrfs_ioctl_send(struct btrfs_root *send_root, const struct btrfs_ioctl_sen
}
sctx->clone_roots = kvzalloc_objs(*sctx->clone_roots,
- arg->clone_sources_count + 1,
- GFP_KERNEL);
+ arg->clone_sources_count + 1);
if (!sctx->clone_roots) {
ret = -ENOMEM;
goto out;
diff --git a/fs/ceph/mds_client.c b/fs/ceph/mds_client.c
index 8933f05f5144..23b6d00643c9 100644
--- a/fs/ceph/mds_client.c
+++ b/fs/ceph/mds_client.c
@@ -4231,7 +4231,7 @@ static void handle_session(struct ceph_mds_session *session,
}
cap_auths = kzalloc_objs(struct ceph_mds_cap_auth,
- cap_auths_num, GFP_KERNEL);
+ cap_auths_num);
if (!cap_auths) {
pr_err_client(cl, "No memory for cap_auths\n");
return;
diff --git a/fs/erofs/zutil.c b/fs/erofs/zutil.c
index 0facb0e77e33..a0ce9226bc02 100644
--- a/fs/erofs/zutil.c
+++ b/fs/erofs/zutil.c
@@ -138,8 +138,7 @@ int __init z_erofs_gbuf_init(void)
if (z_erofs_rsv_nrpages) {
z_erofs_rsvbuf = &z_erofs_gbufpool[total - 1];
z_erofs_rsvbuf->pages = kzalloc_objs(*z_erofs_rsvbuf->pages,
- z_erofs_rsv_nrpages,
- GFP_KERNEL);
+ z_erofs_rsv_nrpages);
if (!z_erofs_rsvbuf->pages) {
z_erofs_rsvbuf = NULL;
z_erofs_rsv_nrpages = 0;
diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
index b6d59385e13d..20e9fdaf4301 100644
--- a/fs/ext4/mballoc.c
+++ b/fs/ext4/mballoc.c
@@ -3816,8 +3816,7 @@ int ext4_mb_init(struct super_block *sb)
sbi->s_mb_nr_global_goals = umin(num_possible_cpus(),
DIV_ROUND_UP(sbi->s_groups_count, 4));
sbi->s_mb_last_groups = kzalloc_objs(ext4_group_t,
- sbi->s_mb_nr_global_goals,
- GFP_KERNEL);
+ sbi->s_mb_nr_global_goals);
if (sbi->s_mb_last_groups == NULL) {
ret = -ENOMEM;
goto out;
diff --git a/fs/isofs/compress.c b/fs/isofs/compress.c
index a17f0f590151..50b4cb3aea87 100644
--- a/fs/isofs/compress.c
+++ b/fs/isofs/compress.c
@@ -334,8 +334,7 @@ static int zisofs_read_folio(struct file *file, struct folio *folio)
pcount = 1;
}
pages = kzalloc_objs(*pages,
- max_t(unsigned int, zisofs_pages_per_cblock, 1),
- GFP_KERNEL);
+ max_t(unsigned int, zisofs_pages_per_cblock, 1));
if (!pages) {
folio_unlock(folio);
return -ENOMEM;
diff --git a/fs/jffs2/fs.c b/fs/jffs2/fs.c
index ff469d44b92f..c3ce2c868f7a 100644
--- a/fs/jffs2/fs.c
+++ b/fs/jffs2/fs.c
@@ -563,7 +563,7 @@ int jffs2_do_fill_super(struct super_block *sb, struct fs_context *fc)
c->inocache_hashsize = calculate_inocache_hashsize(c->flash_size);
c->inocache_list = kzalloc_objs(struct jffs2_inode_cache *,
- c->inocache_hashsize, GFP_KERNEL);
+ c->inocache_hashsize);
if (!c->inocache_list) {
ret = -ENOMEM;
goto out_wbuf;
diff --git a/fs/nfs/callback_xdr.c b/fs/nfs/callback_xdr.c
index 7f317ffa17c2..176873f45677 100644
--- a/fs/nfs/callback_xdr.c
+++ b/fs/nfs/callback_xdr.c
@@ -379,8 +379,7 @@ static __be32 decode_rc_list(struct xdr_stream *xdr,
if (unlikely(p == NULL))
goto out;
rc_list->rcl_refcalls = kmalloc_objs(*rc_list->rcl_refcalls,
- rc_list->rcl_nrefcalls,
- GFP_KERNEL);
+ rc_list->rcl_nrefcalls);
if (unlikely(rc_list->rcl_refcalls == NULL))
goto out;
for (i = 0; i < rc_list->rcl_nrefcalls; i++) {
@@ -420,7 +419,7 @@ static __be32 decode_cb_sequence_args(struct svc_rqst *rqstp,
args->csa_rclists = NULL;
if (args->csa_nrclists) {
args->csa_rclists = kmalloc_objs(*args->csa_rclists,
- args->csa_nrclists, GFP_KERNEL);
+ args->csa_nrclists);
if (unlikely(args->csa_rclists == NULL))
return htonl(NFS4ERR_RESOURCE);
diff --git a/fs/nfs/delegation.c b/fs/nfs/delegation.c
index cf40ced95305..122fb3f14ffb 100644
--- a/fs/nfs/delegation.c
+++ b/fs/nfs/delegation.c
@@ -1603,8 +1603,7 @@ int nfs4_delegation_hash_alloc(struct nfs_server *server)
delegation_buckets = roundup_pow_of_two(nfs_delegation_watermark / 16);
server->delegation_hash_mask = delegation_buckets - 1;
server->delegation_hash_table = kmalloc_objs(*server->delegation_hash_table,
- delegation_buckets,
- GFP_KERNEL);
+ delegation_buckets);
if (!server->delegation_hash_table)
return -ENOMEM;
for (i = 0; i < delegation_buckets; i++)
diff --git a/fs/nfsd/export.c b/fs/nfsd/export.c
index e8441fae01bf..8fdbba7cad96 100644
--- a/fs/nfsd/export.c
+++ b/fs/nfsd/export.c
@@ -480,7 +480,7 @@ fsloc_parse(char **mesg, char *buf, struct nfsd4_fs_locations *fsloc)
return 0;
fsloc->locations = kzalloc_objs(struct nfsd4_fs_location,
- fsloc->locations_count, GFP_KERNEL);
+ fsloc->locations_count);
if (!fsloc->locations)
return -ENOMEM;
for (i=0; i < fsloc->locations_count; i++) {
diff --git a/fs/nfsd/nfs4recover.c b/fs/nfsd/nfs4recover.c
index f72bffca6e0e..b4bf85f96f6e 100644
--- a/fs/nfsd/nfs4recover.c
+++ b/fs/nfsd/nfs4recover.c
@@ -479,7 +479,7 @@ nfs4_legacy_state_init(struct net *net)
int i;
nn->reclaim_str_hashtbl = kmalloc_objs(struct list_head,
- CLIENT_HASH_SIZE, GFP_KERNEL);
+ CLIENT_HASH_SIZE);
if (!nn->reclaim_str_hashtbl)
return -ENOMEM;
@@ -1356,7 +1356,7 @@ nfs4_cld_state_init(struct net *net)
int i;
nn->reclaim_str_hashtbl = kmalloc_objs(struct list_head,
- CLIENT_HASH_SIZE, GFP_KERNEL);
+ CLIENT_HASH_SIZE);
if (!nn->reclaim_str_hashtbl)
return -ENOMEM;
diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c
index 74f50670cbe7..6b9c399b89df 100644
--- a/fs/nfsd/nfs4state.c
+++ b/fs/nfsd/nfs4state.c
@@ -2358,7 +2358,7 @@ static struct nfs4_client *alloc_client(struct xdr_netobj name,
if (clp->cl_name.data == NULL)
goto err_no_name;
clp->cl_ownerstr_hashtbl = kmalloc_objs(struct list_head,
- OWNER_HASH_SIZE, GFP_KERNEL);
+ OWNER_HASH_SIZE);
if (!clp->cl_ownerstr_hashtbl)
goto err_no_hashtbl;
clp->cl_callback_wq = alloc_ordered_workqueue("nfsd4_callbacks", 0);
@@ -8966,7 +8966,7 @@ static int nfs4_state_create_net(struct net *net)
if (!nn->unconf_id_hashtbl)
goto err_unconf_id;
nn->sessionid_hashtbl = kmalloc_objs(struct list_head,
- SESSION_HASH_SIZE, GFP_KERNEL);
+ SESSION_HASH_SIZE);
if (!nn->sessionid_hashtbl)
goto err_sessionid;
diff --git a/fs/pstore/ram_core.c b/fs/pstore/ram_core.c
index 7930c886dbf5..ed97494abf60 100644
--- a/fs/pstore/ram_core.c
+++ b/fs/pstore/ram_core.c
@@ -230,7 +230,7 @@ static int persistent_ram_init_ecc(struct persistent_ram_zone *prz,
/* allocate workspace instead of using stack VLA */
prz->ecc_info.par = kmalloc_objs(*prz->ecc_info.par,
- prz->ecc_info.ecc_size, GFP_KERNEL);
+ prz->ecc_info.ecc_size);
if (!prz->ecc_info.par) {
pr_err("cannot allocate ECC parity workspace\n");
return -ENOMEM;
diff --git a/fs/smb/client/smbdirect.c b/fs/smb/client/smbdirect.c
index 77f36d68621b..c79304012b08 100644
--- a/fs/smb/client/smbdirect.c
+++ b/fs/smb/client/smbdirect.c
@@ -2806,7 +2806,7 @@ static int allocate_mr_list(struct smbdirect_socket *sc)
}
mr->sgt.sgl = kzalloc_objs(struct scatterlist,
- sp->max_frmr_depth, GFP_KERNEL);
+ sp->max_frmr_depth);
if (!mr->sgt.sgl) {
ret = -ENOMEM;
log_rdma_mr(ERR, "failed to allocate sgl\n");
diff --git a/fs/squashfs/file.c b/fs/squashfs/file.c
index 8b45020b4a13..d83594ce91d2 100644
--- a/fs/squashfs/file.c
+++ b/fs/squashfs/file.c
@@ -104,8 +104,7 @@ static struct meta_index *empty_meta_index(struct inode *inode, int offset,
* if a 'large' file is read.
*/
msblk->meta_index = kzalloc_objs(*(msblk->meta_index),
- SQUASHFS_META_SLOTS,
- GFP_KERNEL);
+ SQUASHFS_META_SLOTS);
if (msblk->meta_index == NULL) {
ERROR("Failed to allocate meta_index\n");
goto failed;
diff --git a/fs/udf/super.c b/fs/udf/super.c
index ccbf16f50ba5..27f463fd1d89 100644
--- a/fs/udf/super.c
+++ b/fs/udf/super.c
@@ -1757,7 +1757,7 @@ static noinline int udf_process_sequence(
data.size_part_descs = PART_DESC_ALLOC_STEP;
data.num_part_descs = 0;
data.part_descs_loc = kzalloc_objs(*data.part_descs_loc,
- data.size_part_descs, GFP_KERNEL);
+ data.size_part_descs);
if (!data.part_descs_loc)
return -ENOMEM;