diff --git a/fs/io_uring.c b/fs/io_uring.c index 367b339f4dc39ec64b1faed63e4885cb2074ddb5..fe41bd61aefcfa4846b9813ae4537d3cadf7ebf6 100644 --- a/fs/io_uring.c +++ b/fs/io_uring.c @@ -3833,10 +3833,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)