Skip to content

Commit f3a640c

Browse files
committed
io_uring/net: ensure async prep handlers always initialize ->done_io
If we get a request with IOSQE_ASYNC set, then we first run the prep async handlers. But if we then fail setting it up and want to post a CQE with -EINVAL, we use ->done_io. This was previously guarded with REQ_F_PARTIAL_IO, and the normal setup handlers do set it up before any potential errors, but we need to cover the async setup too. Fixes: 9817ad8 ("io_uring/net: remove dependency on REQ_F_PARTIAL_IO for sr->done_io") Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent 2b35b8b commit f3a640c

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

io_uring/net.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,10 @@ int io_send_prep_async(struct io_kiocb *req)
326326
struct io_async_msghdr *io;
327327
int ret;
328328

329-
if (!zc->addr || req_has_async_data(req))
329+
if (req_has_async_data(req))
330+
return 0;
331+
zc->done_io = 0;
332+
if (!zc->addr)
330333
return 0;
331334
io = io_msg_alloc_async_prep(req);
332335
if (!io)
@@ -353,8 +356,10 @@ static int io_setup_async_addr(struct io_kiocb *req,
353356

354357
int io_sendmsg_prep_async(struct io_kiocb *req)
355358
{
359+
struct io_sr_msg *sr = io_kiocb_to_cmd(req, struct io_sr_msg);
356360
int ret;
357361

362+
sr->done_io = 0;
358363
if (!io_msg_alloc_async_prep(req))
359364
return -ENOMEM;
360365
ret = io_sendmsg_copy_hdr(req, req->async_data);
@@ -608,9 +613,11 @@ static int io_recvmsg_copy_hdr(struct io_kiocb *req,
608613

609614
int io_recvmsg_prep_async(struct io_kiocb *req)
610615
{
616+
struct io_sr_msg *sr = io_kiocb_to_cmd(req, struct io_sr_msg);
611617
struct io_async_msghdr *iomsg;
612618
int ret;
613619

620+
sr->done_io = 0;
614621
if (!io_msg_alloc_async_prep(req))
615622
return -ENOMEM;
616623
iomsg = req->async_data;

0 commit comments

Comments
 (0)