提交 8c3e80dd 编写于 作者: P Pavel Begunkov 提交者: Joseph Qi

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

to #26323588

commit 8fef80bf56a49c60b457dedb99fd6c5279a5dbe1 upstream.

openat() and statx() may have allocated ->open.filename, which should be
be put. Add cleanup handlers for them.
Signed-off-by: NPavel Begunkov <asml.silence@gmail.com>
Signed-off-by: NJens Axboe <axboe@kernel.dk>
Signed-off-by: NJoseph Qi <joseph.qi@linux.alibaba.com>
Acked-by: NXiaoguang Wang <xiaoguang.wang@linux.alibaba.com>
上级 36d6c6ed
...@@ -2534,6 +2534,7 @@ static int io_openat_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe) ...@@ -2534,6 +2534,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;
} }
...@@ -2572,6 +2573,7 @@ static int io_openat2_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe) ...@@ -2572,6 +2573,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;
} }
...@@ -2603,6 +2605,7 @@ static int io_openat2(struct io_kiocb *req, struct io_kiocb **nxt, ...@@ -2603,6 +2605,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);
...@@ -2762,6 +2765,7 @@ static int io_statx_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe) ...@@ -2762,6 +2765,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;
} }
...@@ -2799,6 +2803,7 @@ static int io_statx(struct io_kiocb *req, struct io_kiocb **nxt, ...@@ -2799,6 +2803,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);
...@@ -4220,6 +4225,11 @@ static void io_cleanup_req(struct io_kiocb *req) ...@@ -4220,6 +4225,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% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册