Skip to content

Commit 3ed159c

Browse files
Anuj Guptaaxboe
authored andcommitted
io_uring: fix error handling for io_uring_cmd
Commit 97b388d ("io_uring: handle completions in the core") moved the error handling from handler to core. But for io_uring_cmd handler we end up completing more than once (both in handler and in core) leading to use_after_free. Change io_uring_cmd handler to avoid calling io_uring_cmd_done in case of error. Fixes: 97b388d ("io_uring: handle completions in the core") Signed-off-by: Anuj Gupta <[email protected]> Signed-off-by: Kanchan Joshi <[email protected]> Link: https://lore.kernel.org/r/[email protected] [axboe: fix ret vs req typo] Signed-off-by: Jens Axboe <[email protected]>
1 parent d1f6222 commit 3ed159c

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

io_uring/uring_cmd.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,9 @@ int io_uring_cmd(struct io_kiocb *req, unsigned int issue_flags)
106106
}
107107

108108
if (ret != -EIOCBQUEUED) {
109-
io_uring_cmd_done(ioucmd, ret, 0);
109+
if (ret < 0)
110+
req_set_fail(req);
111+
io_req_set_res(req, ret, 0);
110112
return IOU_OK;
111113
}
112114

0 commit comments

Comments
 (0)