diff options
author | Pavel Begunkov <asml.silence@gmail.com> | 2020-07-15 22:20:45 +0300 |
---|---|---|
committer | Jens Axboe <axboe@kernel.dk> | 2020-07-15 22:35:56 +0300 |
commit | 681fda8d27a66f7e65ff7f2d200d7635e64a8d05 (patch) | |
tree | 51f399094bc1ae6b35b093605ee055d77a77b137 /fs | |
parent | 16d598030a37853a7a6b4384cad19c9c0af2f021 (diff) | |
download | linux-681fda8d27a66f7e65ff7f2d200d7635e64a8d05.tar.xz |
io_uring: fix recvmsg memory leak with buffer selection
io_recvmsg() doesn't free memory allocated for struct io_buffer. This can
causes a leak when used with automatic buffer selection.
Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/io_uring.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/fs/io_uring.c b/fs/io_uring.c index 9fd7e69696c3..74bc4a04befa 100644 --- a/fs/io_uring.c +++ b/fs/io_uring.c @@ -3845,10 +3845,16 @@ static int io_recvmsg(struct io_kiocb *req, bool force_nonblock) ret = __sys_recvmsg_sock(sock, &kmsg->msg, req->sr_msg.msg, kmsg->uaddr, flags); - if (force_nonblock && ret == -EAGAIN) - return io_setup_async_msg(req, kmsg); + if (force_nonblock && ret == -EAGAIN) { + ret = io_setup_async_msg(req, kmsg); + if (ret != -EAGAIN) + kfree(kbuf); + return ret; + } if (ret == -ERESTARTSYS) ret = -EINTR; + if (kbuf) + kfree(kbuf); } if (kmsg && kmsg->iov != kmsg->fast_iov) |