diff options
| author | Kees Cook <kees@kernel.org> | 2026-02-21 23:46:04 -0800 |
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2026-02-22 08:26:33 -0800 |
| commit | 189f164e573e18d9f8876dbd3ad8fcbe11f93037 (patch) | |
| tree | 733382723a15ea29b7c9f3dde3bcb281f0b3c287 /fs/btrfs | |
| parent | 32a92f8c89326985e05dce8b22d3f0aa07a3e1bd (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/btrfs')
| -rw-r--r-- | fs/btrfs/fiemap.c | 2 | ||||
| -rw-r--r-- | fs/btrfs/scrub.c | 5 | ||||
| -rw-r--r-- | fs/btrfs/send.c | 6 |
3 files changed, 5 insertions, 8 deletions
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; |
