diff options
| author | Ming Lei <[email protected]> | 2022-07-30 09:27:48 +0000 |
|---|---|---|
| committer | Jens Axboe <[email protected]> | 2022-08-03 03:13:40 +0000 |
| commit | 93d71ec89d5fb2bc431fe7e0ff7ca819bf6dc601 (patch) | |
| tree | 70a4a44f61d172bcca0c97b49d8d7f3c063837db | |
| parent | ublk_drv: cancel device even though disk isn't up (diff) | |
| download | kernel-93d71ec89d5fb2bc431fe7e0ff7ca819bf6dc601.tar.gz kernel-93d71ec89d5fb2bc431fe7e0ff7ca819bf6dc601.zip | |
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 <[email protected]>
Signed-off-by: Ming Lei <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Jens Axboe <[email protected]>
| -rw-r--r-- | drivers/block/ublk_drv.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/drivers/block/ublk_drv.c b/drivers/block/ublk_drv.c index 7ece4c2ef062..ae98e81b21ce 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; } |
