Commit 8fef80bf authored by Pavel Begunkov's avatar Pavel Begunkov Committed by Jens Axboe

io_uring: add cleanup for openat()/statx()

openat() and statx() may have allocated ->open.filename, which should be
be put. Add cleanup handlers for them.
Signed-off-by: default avatarPavel Begunkov <asml.silence@gmail.com>
Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent 99bc4c38
...@@ -2537,6 +2537,7 @@ static int io_openat_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe) ...@@ -2537,6 +2537,7 @@ static int io_openat_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe)
return ret; return ret;
} }
req->flags |= REQ_F_NEED_CLEANUP;
return 0; return 0;
} }
...@@ -2575,6 +2576,7 @@ static int io_openat2_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe) ...@@ -2575,6 +2576,7 @@ static int io_openat2_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe)
return ret; return ret;
} }
req->flags |= REQ_F_NEED_CLEANUP;
return 0; return 0;
} }
...@@ -2606,6 +2608,7 @@ static int io_openat2(struct io_kiocb *req, struct io_kiocb **nxt, ...@@ -2606,6 +2608,7 @@ static int io_openat2(struct io_kiocb *req, struct io_kiocb **nxt,
} }
err: err:
putname(req->open.filename); putname(req->open.filename);
req->flags &= ~REQ_F_NEED_CLEANUP;
if (ret < 0) if (ret < 0)
req_set_fail_links(req); req_set_fail_links(req);
io_cqring_add_event(req, ret); io_cqring_add_event(req, ret);
...@@ -2765,6 +2768,7 @@ static int io_statx_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe) ...@@ -2765,6 +2768,7 @@ static int io_statx_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe)
return ret; return ret;
} }
req->flags |= REQ_F_NEED_CLEANUP;
return 0; return 0;
} }
...@@ -2802,6 +2806,7 @@ static int io_statx(struct io_kiocb *req, struct io_kiocb **nxt, ...@@ -2802,6 +2806,7 @@ static int io_statx(struct io_kiocb *req, struct io_kiocb **nxt,
ret = cp_statx(&stat, ctx->buffer); ret = cp_statx(&stat, ctx->buffer);
err: err:
putname(ctx->filename); putname(ctx->filename);
req->flags &= ~REQ_F_NEED_CLEANUP;
if (ret < 0) if (ret < 0)
req_set_fail_links(req); req_set_fail_links(req);
io_cqring_add_event(req, ret); io_cqring_add_event(req, ret);
...@@ -4223,6 +4228,11 @@ static void io_cleanup_req(struct io_kiocb *req) ...@@ -4223,6 +4228,11 @@ static void io_cleanup_req(struct io_kiocb *req)
if (io->msg.iov != io->msg.fast_iov) if (io->msg.iov != io->msg.fast_iov)
kfree(io->msg.iov); kfree(io->msg.iov);
break; break;
case IORING_OP_OPENAT:
case IORING_OP_OPENAT2:
case IORING_OP_STATX:
putname(req->open.filename);
break;
} }
req->flags &= ~REQ_F_NEED_CLEANUP; req->flags &= ~REQ_F_NEED_CLEANUP;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment