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)
commit9172dbf3a6d30fb80aa2f550003961450bb4c0bb
tree6e84e807d068f29ca4d39b351260f1b1804c5981
parent6f1a182a8750a679698366b021969a57ec589313
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: 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