Skip to content

Commit 3e2224c

Browse files
Matthew Wilcox (Oracle)axboe
authored andcommitted
io_uring: Fix return value from alloc_fixed_file_ref_node
alloc_fixed_file_ref_node() currently returns an ERR_PTR on failure. io_sqe_files_unregister() expects it to return NULL and since it can only return -ENOMEM, it makes more sense to change alloc_fixed_file_ref_node() to behave that way. Fixes: 1ffc542 ("io_uring: fix io_sqe_files_unregister() hangs") Reported-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org> Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent 170b3bb commit 3e2224c

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

fs/io_uring.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7696,12 +7696,12 @@ static struct fixed_file_ref_node *alloc_fixed_file_ref_node(
76967696

76977697
ref_node = kzalloc(sizeof(*ref_node), GFP_KERNEL);
76987698
if (!ref_node)
7699-
return ERR_PTR(-ENOMEM);
7699+
return NULL;
77007700

77017701
if (percpu_ref_init(&ref_node->refs, io_file_data_ref_zero,
77027702
0, GFP_KERNEL)) {
77037703
kfree(ref_node);
7704-
return ERR_PTR(-ENOMEM);
7704+
return NULL;
77057705
}
77067706
INIT_LIST_HEAD(&ref_node->node);
77077707
INIT_LIST_HEAD(&ref_node->file_list);
@@ -7795,9 +7795,9 @@ static int io_sqe_files_register(struct io_ring_ctx *ctx, void __user *arg,
77957795
}
77967796

77977797
ref_node = alloc_fixed_file_ref_node(ctx);
7798-
if (IS_ERR(ref_node)) {
7798+
if (!ref_node) {
77997799
io_sqe_files_unregister(ctx);
7800-
return PTR_ERR(ref_node);
7800+
return -ENOMEM;
78017801
}
78027802

78037803
io_sqe_files_set_node(file_data, ref_node);
@@ -7897,8 +7897,8 @@ static int __io_sqe_files_update(struct io_ring_ctx *ctx,
78977897
return -EINVAL;
78987898

78997899
ref_node = alloc_fixed_file_ref_node(ctx);
7900-
if (IS_ERR(ref_node))
7901-
return PTR_ERR(ref_node);
7900+
if (!ref_node)
7901+
return -ENOMEM;
79027902

79037903
done = 0;
79047904
fds = u64_to_user_ptr(up->fds);

0 commit comments

Comments
 (0)