move_addr_to_kernel can fail, like if the user provides a bad sockaddr pointer. In this case where the failure happens on ->prep() we don't have a chance to clean the request later, so handle it here. Signed-off-by: Gabriel Krisman Bertazi <krisman@xxxxxxx> --- io_uring/net.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/io_uring/net.c b/io_uring/net.c index 0a48596429d9..c3377e70aeeb 100644 --- a/io_uring/net.c +++ b/io_uring/net.c @@ -1657,6 +1657,7 @@ int io_connect_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe) { struct io_connect *conn = io_kiocb_to_cmd(req, struct io_connect); struct io_async_msghdr *io; + int ret; if (sqe->len || sqe->buf_index || sqe->rw_flags || sqe->splice_fd_in) return -EINVAL; @@ -1669,7 +1670,10 @@ int io_connect_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe) if (unlikely(!io)) return -ENOMEM; - return move_addr_to_kernel(conn->addr, conn->addr_len, &io->addr); + ret = move_addr_to_kernel(conn->addr, conn->addr_len, &io->addr); + if (ret) + io_netmsg_recycle(req, 0); + return ret; } int io_connect(struct io_kiocb *req, unsigned int issue_flags) -- 2.44.0