]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
io_uring: get an active ref_node from files_data
authorPavel Begunkov <asml.silence@gmail.com>
Wed, 18 Nov 2020 14:56:25 +0000 (14:56 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 2 Dec 2020 07:51:43 +0000 (08:51 +0100)
commit 1e5d770bb8a23dd01e28e92f4fb0b1093c8bdbe6 upstream.

An active ref_node always can be found in ctx->files_data, it's much
safer to get it this way instead of poking into files_data->ref_list.

Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
Cc: stable@vger.kernel.org # v5.7+
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/io_uring.c

index e74a56f6915c00d0fd6d59b6505aebd50048b892..ba2d56e44c6a76b562ea02d144803eb6d182c63f 100644 (file)
@@ -6854,9 +6854,8 @@ static int io_sqe_files_unregister(struct io_ring_ctx *ctx)
                return -ENXIO;
 
        spin_lock(&data->lock);
-       if (!list_empty(&data->ref_list))
-               ref_node = list_first_entry(&data->ref_list,
-                               struct fixed_file_ref_node, node);
+       ref_node = container_of(data->cur_refs, struct fixed_file_ref_node,
+                               refs);
        spin_unlock(&data->lock);
        if (ref_node)
                percpu_ref_kill(&ref_node->refs);