mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-01-10 07:10:27 +00:00
io_uring: fix refcounting with batched allocations at OOM
In case of out of memory the second argument of percpu_ref_put_many() in io_submit_sqes() may evaluate into "nr - (-EAGAIN)", that is clearly wrong. Fixes: 2b85edfc0c90 ("io_uring: batch getting pcpu references") Signed-off-by: Pavel Begunkov <asml.silence@gmail.com> Signed-off-by: Jens Axboe <axboe@kernel.dk>
This commit is contained in:
parent
8cdf2193a3
commit
9466f43741
@ -4830,8 +4830,11 @@ static int io_submit_sqes(struct io_ring_ctx *ctx, unsigned int nr,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (submitted != nr)
|
if (unlikely(submitted != nr)) {
|
||||||
percpu_ref_put_many(&ctx->refs, nr - submitted);
|
int ref_used = (submitted == -EAGAIN) ? 0 : submitted;
|
||||||
|
|
||||||
|
percpu_ref_put_many(&ctx->refs, nr - ref_used);
|
||||||
|
}
|
||||||
if (link)
|
if (link)
|
||||||
io_queue_link_head(link);
|
io_queue_link_head(link);
|
||||||
if (statep)
|
if (statep)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user