aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fs/io_uring.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/fs/io_uring.c b/fs/io_uring.c
index 18cecb6a0151..84efb8956734 100644
--- a/fs/io_uring.c
+++ b/fs/io_uring.c
@@ -2443,7 +2443,7 @@ static int io_sqe_buffer_unregister(struct io_ring_ctx *ctx)
2443 2443
2444 if (ctx->account_mem) 2444 if (ctx->account_mem)
2445 io_unaccount_mem(ctx->user, imu->nr_bvecs); 2445 io_unaccount_mem(ctx->user, imu->nr_bvecs);
2446 kfree(imu->bvec); 2446 kvfree(imu->bvec);
2447 imu->nr_bvecs = 0; 2447 imu->nr_bvecs = 0;
2448 } 2448 }
2449 2449
@@ -2535,9 +2535,9 @@ static int io_sqe_buffer_register(struct io_ring_ctx *ctx, void __user *arg,
2535 if (!pages || nr_pages > got_pages) { 2535 if (!pages || nr_pages > got_pages) {
2536 kfree(vmas); 2536 kfree(vmas);
2537 kfree(pages); 2537 kfree(pages);
2538 pages = kmalloc_array(nr_pages, sizeof(struct page *), 2538 pages = kvmalloc_array(nr_pages, sizeof(struct page *),
2539 GFP_KERNEL); 2539 GFP_KERNEL);
2540 vmas = kmalloc_array(nr_pages, 2540 vmas = kvmalloc_array(nr_pages,
2541 sizeof(struct vm_area_struct *), 2541 sizeof(struct vm_area_struct *),
2542 GFP_KERNEL); 2542 GFP_KERNEL);
2543 if (!pages || !vmas) { 2543 if (!pages || !vmas) {
@@ -2549,7 +2549,7 @@ static int io_sqe_buffer_register(struct io_ring_ctx *ctx, void __user *arg,
2549 got_pages = nr_pages; 2549 got_pages = nr_pages;
2550 } 2550 }
2551 2551
2552 imu->bvec = kmalloc_array(nr_pages, sizeof(struct bio_vec), 2552 imu->bvec = kvmalloc_array(nr_pages, sizeof(struct bio_vec),
2553 GFP_KERNEL); 2553 GFP_KERNEL);
2554 ret = -ENOMEM; 2554 ret = -ENOMEM;
2555 if (!imu->bvec) { 2555 if (!imu->bvec) {
@@ -2588,6 +2588,7 @@ static int io_sqe_buffer_register(struct io_ring_ctx *ctx, void __user *arg,
2588 } 2588 }
2589 if (ctx->account_mem) 2589 if (ctx->account_mem)
2590 io_unaccount_mem(ctx->user, nr_pages); 2590 io_unaccount_mem(ctx->user, nr_pages);
2591 kvfree(imu->bvec);
2591 goto err; 2592 goto err;
2592 } 2593 }
2593 2594
@@ -2610,12 +2611,12 @@ static int io_sqe_buffer_register(struct io_ring_ctx *ctx, void __user *arg,
2610 2611
2611 ctx->nr_user_bufs++; 2612 ctx->nr_user_bufs++;
2612 } 2613 }
2613 kfree(pages); 2614 kvfree(pages);
2614 kfree(vmas); 2615 kvfree(vmas);
2615 return 0; 2616 return 0;
2616err: 2617err:
2617 kfree(pages); 2618 kvfree(pages);
2618 kfree(vmas); 2619 kvfree(vmas);
2619 io_sqe_buffer_unregister(ctx); 2620 io_sqe_buffer_unregister(ctx);
2620 return ret; 2621 return ret;
2621} 2622}