OSDN Git Service

io_uring: fix flush req->refs underflow
authorPavel Begunkov <asml.silence@gmail.com>
Tue, 26 May 2020 17:34:02 +0000 (20:34 +0300)
committerJens Axboe <axboe@kernel.dk>
Tue, 26 May 2020 19:31:08 +0000 (13:31 -0600)
In io_uring_cancel_files(), after refcount_sub_and_test() leaves 0
req->refs, it calls io_put_req(), which would also put a ref. Call
io_free_req() instead.

Cc: stable@vger.kernel.org
Fixes: 2ca10259b418 ("io_uring: prune request from overflow list on flush")
Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
fs/io_uring.c

index 0b51f21..37422fc 100644 (file)
@@ -7534,7 +7534,7 @@ static void io_uring_cancel_files(struct io_ring_ctx *ctx,
                         * all we had, then we're done with this request.
                         */
                        if (refcount_sub_and_test(2, &cancel_req->refs)) {
-                               io_put_req(cancel_req);
+                               io_free_req(cancel_req);
                                finish_wait(&ctx->inflight_wait, &wait);
                                continue;
                        }