OSDN Git Service

io_uring: Fix leaked shadow_req
authorPavel Begunkov <asml.silence@gmail.com>
Sun, 27 Oct 2019 19:10:36 +0000 (22:10 +0300)
committerJens Axboe <axboe@kernel.dk>
Mon, 28 Oct 2019 03:29:18 +0000 (21:29 -0600)
io_queue_link_head() owns shadow_req after taking it as an argument.
By not freeing it in case of an error, it can leak the request along
with taken ctx->refs.

Reviewed-by: Jackie Liu <liuyun01@kylinos.cn>
Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
fs/io_uring.c

index a30c4f6..ba14310 100644 (file)
@@ -2413,6 +2413,7 @@ static int io_queue_link_head(struct io_ring_ctx *ctx, struct io_kiocb *req,
        if (ret) {
                if (ret != -EIOCBQUEUED) {
                        io_free_req(req);
+                       __io_free_req(shadow);
                        io_cqring_add_event(ctx, s->sqe->user_data, ret);
                        return 0;
                }