History

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.

Ming Lei committed 4 years ago

Commit 93d71ec1 parent a8ce5f51 file · +5 −0Browse files

Unified · Split

drivers/block/ublk_drv.c+5−0
@@ -1190,6 +1190,11 @@ static int ublk_ctrl_start_dev(struct io_uring_cmd *cmd) · 1189 unmodified lines
11901190 get_device(&ub->cdev_dev);
11911191 ret = add_disk(disk);
11921192 if (ret) {
1193+ /*
1194+ * Has to drop the reference since ->free_disk won't be
1195+ * called in case of add_disk failure.
1196+ */
1197+ ublk_put_device(ub);
11931198 put_disk(disk);
11941199 goto out_unlock;
11951200 }