diff options
Diffstat (limited to 'io_uring/rsrc.c')
-rw-r--r-- | io_uring/rsrc.c | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/io_uring/rsrc.c b/io_uring/rsrc.c index 3107a03d56b8..c9105030f0e3 100644 --- a/io_uring/rsrc.c +++ b/io_uring/rsrc.c @@ -973,26 +973,36 @@ unlock: } EXPORT_SYMBOL_GPL(io_buffer_register_bvec); -void io_buffer_unregister_bvec(struct io_uring_cmd *cmd, unsigned int index, - unsigned int issue_flags) +int io_buffer_unregister_bvec(struct io_uring_cmd *cmd, unsigned int index, + unsigned int issue_flags) { struct io_ring_ctx *ctx = cmd_to_io_kiocb(cmd)->ctx; struct io_rsrc_data *data = &ctx->buf_table; struct io_rsrc_node *node; + int ret = 0; io_ring_submit_lock(ctx, issue_flags); - if (index >= data->nr) + if (index >= data->nr) { + ret = -EINVAL; goto unlock; + } index = array_index_nospec(index, data->nr); node = data->nodes[index]; - if (!node || !node->buf->is_kbuf) + if (!node) { + ret = -EINVAL; goto unlock; + } + if (!node->buf->is_kbuf) { + ret = -EBUSY; + goto unlock; + } io_put_rsrc_node(ctx, node); data->nodes[index] = NULL; unlock: io_ring_submit_unlock(ctx, issue_flags); + return ret; } EXPORT_SYMBOL_GPL(io_buffer_unregister_bvec); |