Skip to content

Commit b9d6937

Browse files
isilenceaxboe
authored andcommitted
io_uring: fix invalid hybrid polling ctx leaks
It has already allocated the ctx by the point where it checks the hybrid poll configuration, plain return leaks the memory. Fixes: 01ee194 ("io_uring: add support for hybrid IOPOLL") Signed-off-by: Pavel Begunkov <[email protected]> Reviewed-by: Anuj Gupta <[email protected]> Link: https://lore.kernel.org/r/b57f2608088020501d352fcdeebdb949e281d65b.1731468230.git.asml.silence@gmail.com Signed-off-by: Jens Axboe <[email protected]>
1 parent a43e236 commit b9d6937

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

io_uring/io_uring.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3616,11 +3616,6 @@ static __cold int io_uring_create(unsigned entries, struct io_uring_params *p,
36163616
if (!(ctx->flags & IORING_SETUP_NO_SQARRAY))
36173617
static_branch_inc(&io_key_has_sqarray);
36183618

3619-
/* HYBRID_IOPOLL only valid with IOPOLL */
3620-
if ((ctx->flags & (IORING_SETUP_IOPOLL|IORING_SETUP_HYBRID_IOPOLL)) ==
3621-
IORING_SETUP_HYBRID_IOPOLL)
3622-
return -EINVAL;
3623-
36243619
if ((ctx->flags & IORING_SETUP_DEFER_TASKRUN) &&
36253620
!(ctx->flags & IORING_SETUP_IOPOLL) &&
36263621
!(ctx->flags & IORING_SETUP_SQPOLL))
@@ -3671,6 +3666,11 @@ static __cold int io_uring_create(unsigned entries, struct io_uring_params *p,
36713666
ctx->notify_method = TWA_SIGNAL;
36723667
}
36733668

3669+
/* HYBRID_IOPOLL only valid with IOPOLL */
3670+
if ((ctx->flags & (IORING_SETUP_IOPOLL|IORING_SETUP_HYBRID_IOPOLL)) ==
3671+
IORING_SETUP_HYBRID_IOPOLL)
3672+
goto err;
3673+
36743674
/*
36753675
* For DEFER_TASKRUN we require the completion task to be the same as the
36763676
* submission task. This implies that there is only one submitter, so enforce

0 commit comments

Comments
 (0)