2020-06-05 09:34:23

by Denis Efremov (Oracle)

[permalink] [raw]
Subject: [PATCH] io_uring: use kvfree() in io_sqe_buffer_register()

Use kvfree() to free the pages and vmas, since they are allocated by
kvmalloc_array() in a loop.

Fixes: d4ef647510b1 ("io_uring: avoid page allocation warnings")
Cc: [email protected]
Signed-off-by: Denis Efremov <[email protected]>
---
I checked the v1 d4ef647510b1 discussion and these lines are using
kvfree() https://lkml.org/lkml/2019/5/1/254. This was somehow missed
in v2.

fs/io_uring.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/fs/io_uring.c b/fs/io_uring.c
index 9d4bd0d3a080..defb8a3538fc 100644
--- a/fs/io_uring.c
+++ b/fs/io_uring.c
@@ -7160,8 +7160,8 @@ static int io_sqe_buffer_register(struct io_ring_ctx *ctx, void __user *arg,

ret = 0;
if (!pages || nr_pages > got_pages) {
- kfree(vmas);
- kfree(pages);
+ kvfree(vmas);
+ kvfree(pages);
pages = kvmalloc_array(nr_pages, sizeof(struct page *),
GFP_KERNEL);
vmas = kvmalloc_array(nr_pages,
--
2.26.2


2020-06-05 12:49:30

by Jens Axboe

[permalink] [raw]
Subject: Re: [PATCH] io_uring: use kvfree() in io_sqe_buffer_register()

On 6/5/20 3:32 AM, Denis Efremov wrote:
> Use kvfree() to free the pages and vmas, since they are allocated by
> kvmalloc_array() in a loop.

Applied, thanks.

--
Jens Axboe