diff options
| author | Caleb Sander Mateos <csander@purestorage.com> | 2025-10-15 11:25:54 -0600 |
|---|---|---|
| committer | Jens Axboe <axboe@kernel.dk> | 2025-11-04 09:32:09 -0700 |
| commit | 4b25b75c30d90a2ad45eb6c79d4c71fdbb06bb4e (patch) | |
| tree | 919a2aa690726da4e2e1a7471a6f9f63157bc997 | |
| parent | ffce324364318220acf83e576eac06549cbf9911 (diff) | |
io_uring/memmap: return bool from io_mem_alloc_compound()
io_mem_alloc_compound() returns either ERR_PTR(-ENOMEM) or a virtual
address for the allocated memory, but its caller just checks whether the
result is an error. Return a bool success value instead.
Signed-off-by: Caleb Sander Mateos <csander@purestorage.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
| -rw-r--r-- | io_uring/memmap.c | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/io_uring/memmap.c b/io_uring/memmap.c index aa388ecd4754..67b7b17ece31 100644 --- a/io_uring/memmap.c +++ b/io_uring/memmap.c @@ -15,26 +15,26 @@ #include "rsrc.h" #include "zcrx.h" -static void *io_mem_alloc_compound(struct page **pages, int nr_pages, - size_t size, gfp_t gfp) +static bool io_mem_alloc_compound(struct page **pages, int nr_pages, + size_t size, gfp_t gfp) { struct page *page; int i, order; order = get_order(size); if (order > MAX_PAGE_ORDER) - return ERR_PTR(-ENOMEM); + return false; else if (order) gfp |= __GFP_COMP; page = alloc_pages(gfp, order); if (!page) - return ERR_PTR(-ENOMEM); + return false; for (i = 0; i < nr_pages; i++) pages[i] = page + i; - return page_address(page); + return true; } struct page **io_pin_pages(unsigned long uaddr, unsigned long len, int *npages) @@ -159,14 +159,12 @@ static int io_region_allocate_pages(struct io_ring_ctx *ctx, size_t size = (size_t) mr->nr_pages << PAGE_SHIFT; unsigned long nr_allocated; struct page **pages; - void *p; pages = kvmalloc_array(mr->nr_pages, sizeof(*pages), gfp); if (!pages) return -ENOMEM; - p = io_mem_alloc_compound(pages, mr->nr_pages, size, gfp); - if (!IS_ERR(p)) { + if (io_mem_alloc_compound(pages, mr->nr_pages, size, gfp)) { mr->flags |= IO_REGION_F_SINGLE_REF; goto done; } |