Merge tag 'for-6.1/io_uring-2022-10-03' of git://git.kernel.dk/linux
[platform/kernel/linux-rpi.git] / io_uring / io_uring.c
index 62d1f55..00db7ad 100644 (file)
@@ -2818,6 +2818,9 @@ static __cold void io_ring_ctx_wait_and_kill(struct io_ring_ctx *ctx)
                io_kill_timeouts(ctx, NULL, true);
                /* if we failed setting up the ctx, we might not have any rings */
                io_iopoll_try_reap_events(ctx);
+               /* drop cached put refs after potentially doing completions */
+               if (current->io_uring)
+                       io_uring_drop_tctx_refs(current);
        }
 
        INIT_WORK(&ctx->exit_work, io_ring_exit_work);
@@ -3538,6 +3541,10 @@ static __cold int io_uring_create(unsigned entries, struct io_uring_params *p,
                goto err;
        }
 
+       if (ctx->flags & IORING_SETUP_SINGLE_ISSUER
+           && !(ctx->flags & IORING_SETUP_R_DISABLED))
+               ctx->submitter_task = get_task_struct(current);
+
        file = io_uring_get_file(ctx);
        if (IS_ERR(file)) {
                ret = PTR_ERR(file);
@@ -3729,6 +3736,9 @@ static int io_register_enable_rings(struct io_ring_ctx *ctx)
        if (!(ctx->flags & IORING_SETUP_R_DISABLED))
                return -EBADFD;
 
+       if (ctx->flags & IORING_SETUP_SINGLE_ISSUER && !ctx->submitter_task)
+               ctx->submitter_task = get_task_struct(current);
+
        if (ctx->restrictions.registered)
                ctx->restricted = 1;