->free_disk is only called after disk is added successfully, so drop ublk device reference in case of add_disk() failure. Fixes: 6d9e6dfdf3b2 ("ublk: defer disk allocation") Signed-off-by: Ming Lei <ming.lei@xxxxxxxxxx> --- drivers/block/ublk_drv.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/block/ublk_drv.c b/drivers/block/ublk_drv.c index 7ece4c2ef062..00b04f395de0 100644 --- a/drivers/block/ublk_drv.c +++ b/drivers/block/ublk_drv.c @@ -1190,6 +1190,11 @@ static int ublk_ctrl_start_dev(struct io_uring_cmd *cmd) get_device(&ub->cdev_dev); ret = add_disk(disk); if (ret) { + /* + * has to drop the reference since ->free_disk won't be + * called in case of add_disk failure + */ + ublk_put_device(ub); put_disk(disk); goto out_unlock; } -- 2.31.1