ublk: handle ublk_set_auto_buf_reg() failure correctly in ublk_fetch()

If ublk_set_auto_buf_reg() fails, we need to unlock and return,
otherwise `ub->mutex` is leaked.

Fixes: 99c1e4eb6a ("ublk: register buffer to local io_uring with provided buf index via UBLK_F_AUTO_BUF_REG")
Reported-by: Caleb Sander Mateos <csander@purestorage.com>
Signed-off-by: Ming Lei <ming.lei@redhat.com>
Link: https://lore.kernel.org/r/20250521025502.71041-2-ming.lei@redhat.com
Reviewed-by: Caleb Sander Mateos <csander@purestorage.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
This commit is contained in:
Ming Lei 2025-05-21 10:54:59 +08:00 committed by Jens Axboe
parent 6f1a182a87
commit 9172dbf3a6

View File

@ -2075,7 +2075,7 @@ static int ublk_fetch(struct io_uring_cmd *cmd, struct ublk_queue *ubq,
if (ublk_support_auto_buf_reg(ubq)) {
ret = ublk_set_auto_buf_reg(cmd);
if (ret)
return ret;
goto out;
}
ublk_fill_io_cmd(io, cmd, buf_addr);