mirror of https://gitee.com/openkylin/linux.git
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: 1ffc54220c
("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>
This commit is contained in:
parent
170b3bbda0
commit
3e2224c586
|
@ -7696,12 +7696,12 @@ static struct fixed_file_ref_node *alloc_fixed_file_ref_node(
|
||||||
|
|
||||||
ref_node = kzalloc(sizeof(*ref_node), GFP_KERNEL);
|
ref_node = kzalloc(sizeof(*ref_node), GFP_KERNEL);
|
||||||
if (!ref_node)
|
if (!ref_node)
|
||||||
return ERR_PTR(-ENOMEM);
|
return NULL;
|
||||||
|
|
||||||
if (percpu_ref_init(&ref_node->refs, io_file_data_ref_zero,
|
if (percpu_ref_init(&ref_node->refs, io_file_data_ref_zero,
|
||||||
0, GFP_KERNEL)) {
|
0, GFP_KERNEL)) {
|
||||||
kfree(ref_node);
|
kfree(ref_node);
|
||||||
return ERR_PTR(-ENOMEM);
|
return NULL;
|
||||||
}
|
}
|
||||||
INIT_LIST_HEAD(&ref_node->node);
|
INIT_LIST_HEAD(&ref_node->node);
|
||||||
INIT_LIST_HEAD(&ref_node->file_list);
|
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,
|
||||||
}
|
}
|
||||||
|
|
||||||
ref_node = alloc_fixed_file_ref_node(ctx);
|
ref_node = alloc_fixed_file_ref_node(ctx);
|
||||||
if (IS_ERR(ref_node)) {
|
if (!ref_node) {
|
||||||
io_sqe_files_unregister(ctx);
|
io_sqe_files_unregister(ctx);
|
||||||
return PTR_ERR(ref_node);
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
io_sqe_files_set_node(file_data, ref_node);
|
io_sqe_files_set_node(file_data, ref_node);
|
||||||
|
@ -7897,8 +7897,8 @@ static int __io_sqe_files_update(struct io_ring_ctx *ctx,
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
ref_node = alloc_fixed_file_ref_node(ctx);
|
ref_node = alloc_fixed_file_ref_node(ctx);
|
||||||
if (IS_ERR(ref_node))
|
if (!ref_node)
|
||||||
return PTR_ERR(ref_node);
|
return -ENOMEM;
|
||||||
|
|
||||||
done = 0;
|
done = 0;
|
||||||
fds = u64_to_user_ptr(up->fds);
|
fds = u64_to_user_ptr(up->fds);
|
||||||
|
|
Loading…
Reference in New Issue