summaryrefslogtreecommitdiff
path: root/fs/fuse/dev_uring.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/fuse/dev_uring.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/fuse/dev_uring.c')
-rw-r--r--fs/fuse/dev_uring.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/fs/fuse/dev_uring.c b/fs/fuse/dev_uring.c
index 5ceb217ced1b..aee37347b652 100644
--- a/fs/fuse/dev_uring.c
+++ b/fs/fuse/dev_uring.c
@@ -231,12 +231,12 @@ static struct fuse_ring *fuse_uring_create(struct fuse_conn *fc)
struct fuse_ring *res = NULL;
size_t max_payload_size;
- ring = kzalloc(sizeof(*fc->ring), GFP_KERNEL_ACCOUNT);
+ ring = kzalloc_obj(*fc->ring, GFP_KERNEL_ACCOUNT);
if (!ring)
return NULL;
- ring->queues = kcalloc(nr_queues, sizeof(struct fuse_ring_queue *),
- GFP_KERNEL_ACCOUNT);
+ ring->queues = kzalloc_objs(struct fuse_ring_queue *, nr_queues,
+ GFP_KERNEL_ACCOUNT);
if (!ring->queues)
goto out_err;
@@ -274,10 +274,10 @@ static struct fuse_ring_queue *fuse_uring_create_queue(struct fuse_ring *ring,
struct fuse_ring_queue *queue;
struct list_head *pq;
- queue = kzalloc(sizeof(*queue), GFP_KERNEL_ACCOUNT);
+ queue = kzalloc_obj(*queue, GFP_KERNEL_ACCOUNT);
if (!queue)
return NULL;
- pq = kcalloc(FUSE_PQ_HASH_SIZE, sizeof(struct list_head), GFP_KERNEL);
+ pq = kzalloc_objs(struct list_head, FUSE_PQ_HASH_SIZE, GFP_KERNEL);
if (!pq) {
kfree(queue);
return NULL;
@@ -1062,7 +1062,7 @@ fuse_uring_create_ring_ent(struct io_uring_cmd *cmd,
}
err = -ENOMEM;
- ent = kzalloc(sizeof(*ent), GFP_KERNEL_ACCOUNT);
+ ent = kzalloc_obj(*ent, GFP_KERNEL_ACCOUNT);
if (!ent)
return ERR_PTR(err);