Merge tag 'for-5.3/block-20190708' of git://git.kernel.dk/linux-block
[platform/kernel/linux-rpi.git] / fs / io_uring.c
index eb6ab15..4ed4b11 100644 (file)
@@ -579,6 +579,7 @@ static struct io_kiocb *io_get_req(struct io_ring_ctx *ctx,
                state->cur_req++;
        }
 
+       req->file = NULL;
        req->ctx = ctx;
        req->flags = 0;
        /* one is dropped after submission, the other at completion */
@@ -1798,10 +1799,8 @@ static int io_req_set_file(struct io_ring_ctx *ctx, const struct sqe_submit *s,
                req->sequence = ctx->cached_sq_head - 1;
        }
 
-       if (!io_op_needs_file(s->sqe)) {
-               req->file = NULL;
+       if (!io_op_needs_file(s->sqe))
                return 0;
-       }
 
        if (flags & IOSQE_FIXED_FILE) {
                if (unlikely(!ctx->user_files ||
@@ -2198,11 +2197,12 @@ static int io_cqring_wait(struct io_ring_ctx *ctx, int min_events,
        }
 
        ret = wait_event_interruptible(ctx->wait, io_cqring_events(ring) >= min_events);
-       if (ret == -ERESTARTSYS)
-               ret = -EINTR;
 
        if (sig)
-               restore_user_sigmask(sig, &sigsaved);
+               restore_user_sigmask(sig, &sigsaved, ret == -ERESTARTSYS);
+
+       if (ret == -ERESTARTSYS)
+               ret = -EINTR;
 
        return READ_ONCE(ring->r.head) == READ_ONCE(ring->r.tail) ? ret : 0;
 }