Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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>

authored by

Caleb Sander Mateos and committed by
Jens Axboe
4b25b75c ffce3243

+6 -8
+6 -8
io_uring/memmap.c
··· 15 15 #include "rsrc.h" 16 16 #include "zcrx.h" 17 17 18 - static void *io_mem_alloc_compound(struct page **pages, int nr_pages, 19 - size_t size, gfp_t gfp) 18 + static bool io_mem_alloc_compound(struct page **pages, int nr_pages, 19 + size_t size, gfp_t gfp) 20 20 { 21 21 struct page *page; 22 22 int i, order; 23 23 24 24 order = get_order(size); 25 25 if (order > MAX_PAGE_ORDER) 26 - return ERR_PTR(-ENOMEM); 26 + return false; 27 27 else if (order) 28 28 gfp |= __GFP_COMP; 29 29 30 30 page = alloc_pages(gfp, order); 31 31 if (!page) 32 - return ERR_PTR(-ENOMEM); 32 + return false; 33 33 34 34 for (i = 0; i < nr_pages; i++) 35 35 pages[i] = page + i; 36 36 37 - return page_address(page); 37 + return true; 38 38 } 39 39 40 40 struct page **io_pin_pages(unsigned long uaddr, unsigned long len, int *npages) ··· 159 159 size_t size = (size_t) mr->nr_pages << PAGE_SHIFT; 160 160 unsigned long nr_allocated; 161 161 struct page **pages; 162 - void *p; 163 162 164 163 pages = kvmalloc_array(mr->nr_pages, sizeof(*pages), gfp); 165 164 if (!pages) 166 165 return -ENOMEM; 167 166 168 - p = io_mem_alloc_compound(pages, mr->nr_pages, size, gfp); 169 - if (!IS_ERR(p)) { 167 + if (io_mem_alloc_compound(pages, mr->nr_pages, size, gfp)) { 170 168 mr->flags |= IO_REGION_F_SINGLE_REF; 171 169 goto done; 172 170 }