ublk_drv: fix ublk device leak in case that add_disk fails
authorMing Lei <ming.lei@redhat.com>
Sat, 30 Jul 2022 09:27:48 +0000 (17:27 +0800)
committerJens Axboe <axboe@kernel.dk>
Wed, 3 Aug 2022 03:13:40 +0000 (21:13 -0600)
commit93d71ec89d5fb2bc431fe7e0ff7ca819bf6dc601
tree70a4a44f61d172bcca0c97b49d8d7f3c063837db
parenta8ce5f52efce3b89ca82ce8798d0d061117465d2
ublk_drv: fix ublk device leak in case that add_disk fails

->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")
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Ming Lei <ming.lei@redhat.com>
Link: https://lore.kernel.org/r/20220730092750.1118167-3-ming.lei@redhat.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
drivers/block/ublk_drv.c