diff options
| author | Caleb Sander Mateos <csander@purestorage.com> | 2025-02-28 16:14:31 -0700 |
|---|---|---|
| committer | Jens Axboe <axboe@kernel.dk> | 2025-02-28 19:15:05 -0700 |
| commit | e6ea7ec494881bcf61b8f0f77f7cb3542f717ff2 (patch) | |
| tree | 4e47f2956a0d392df239cc96e78655f634f64cad /io_uring/rsrc.c | |
| parent | 09fdd35162c289f354326a55d552a8858f6e8072 (diff) | |
io_uring/ublk: report error when unregister operation fails
Indicate to userspace applications if a UBLK_IO_UNREGISTER_IO_BUF
command specifies an invalid buffer index by returning an error code.
Return -EINVAL if no buffer is registered with the given index, and
-EBUSY if the registered buffer is not a kernel bvec.
Signed-off-by: Caleb Sander Mateos <csander@purestorage.com>
Link: https://lore.kernel.org/r/20250228231432.642417-1-csander@purestorage.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
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); |
