aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fs/io_uring.c15
1 files changed, 7 insertions, 8 deletions
diff --git a/fs/io_uring.c b/fs/io_uring.c
index 5954047ee96d..046fc4e1e155 100644
--- a/fs/io_uring.c
+++ b/fs/io_uring.c
@@ -2396,8 +2396,12 @@ static int io_account_mem(struct user_struct *user, unsigned long nr_pages)
2396 2396
2397static void io_mem_free(void *ptr) 2397static void io_mem_free(void *ptr)
2398{ 2398{
2399 struct page *page = virt_to_head_page(ptr); 2399 struct page *page;
2400
2401 if (!ptr)
2402 return;
2400 2403
2404 page = virt_to_head_page(ptr);
2401 if (put_page_testzero(page)) 2405 if (put_page_testzero(page))
2402 free_compound_page(page); 2406 free_compound_page(page);
2403} 2407}
@@ -2816,17 +2820,12 @@ static int io_allocate_scq_urings(struct io_ring_ctx *ctx,
2816 return -EOVERFLOW; 2820 return -EOVERFLOW;
2817 2821
2818 ctx->sq_sqes = io_mem_alloc(size); 2822 ctx->sq_sqes = io_mem_alloc(size);
2819 if (!ctx->sq_sqes) { 2823 if (!ctx->sq_sqes)
2820 io_mem_free(ctx->sq_ring);
2821 return -ENOMEM; 2824 return -ENOMEM;
2822 }
2823 2825
2824 cq_ring = io_mem_alloc(struct_size(cq_ring, cqes, p->cq_entries)); 2826 cq_ring = io_mem_alloc(struct_size(cq_ring, cqes, p->cq_entries));
2825 if (!cq_ring) { 2827 if (!cq_ring)
2826 io_mem_free(ctx->sq_ring);
2827 io_mem_free(ctx->sq_sqes);
2828 return -ENOMEM; 2828 return -ENOMEM;
2829 }
2830 2829
2831 ctx->cq_ring = cq_ring; 2830 ctx->cq_ring = cq_ring;
2832 cq_ring->ring_mask = p->cq_entries - 1; 2831 cq_ring->ring_mask = p->cq_entries - 1;