Skip to content

Commit

Permalink
io_uring: get an active ref_node from files_data
Browse files Browse the repository at this point in the history
commit 1e5d770 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>
  • Loading branch information
isilence authored and gregkh committed Dec 2, 2020
1 parent 38cbdc4 commit c577296
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions fs/io_uring.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit c577296

Please sign in to comment.