io_uring: fix missing io_grab_files()

We won't have valid ring_fd, ring_file in task work. Grab files early.

Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
This commit is contained in:
Pavel Begunkov 2020-06-27 14:04:58 +03:00 committed by Jens Axboe
parent a6d45dd0d4
commit 710c2bfb66

View File

@ -5270,15 +5270,15 @@ static int io_req_defer_prep(struct io_kiocb *req,
if (!sqe)
return 0;
if (io_op_defs[req->opcode].file_table) {
io_req_init_async(req);
ret = io_grab_files(req);
if (unlikely(ret))
return ret;
}
if (for_async || (req->flags & REQ_F_WORK_INITIALIZED)) {
io_req_init_async(req);
if (io_op_defs[req->opcode].file_table) {
ret = io_grab_files(req);
if (unlikely(ret))
return ret;
}
io_req_work_grab_env(req, &io_op_defs[req->opcode]);
}