]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
ublk: handle ublk_set_auto_buf_reg() failure correctly in ublk_fetch()
authorMing Lei <ming.lei@redhat.com>
Wed, 21 May 2025 02:54:59 +0000 (10:54 +0800)
committerJens Axboe <axboe@kernel.dk>
Wed, 21 May 2025 20:30:28 +0000 (14:30 -0600)
If ublk_set_auto_buf_reg() fails, we need to unlock and return,
otherwise `ub->mutex` is leaked.

Fixes: 99c1e4eb6a3f ("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>
drivers/block/ublk_drv.c

index 2474788ef263129e130ee46c85fa8411ae3122c0..7a78b735c12fd86db4e0c2f3b597646bf9d49878 100644 (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);