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
1190 get_device(&ub->cdev_dev);1190 get_device(&ub->cdev_dev);
1191 ret = add_disk(disk);1191 ret = add_disk(disk);
1192 if (ret) {1192 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);
1193 put_disk(disk);1198 put_disk(disk);
1194 goto out_unlock;1199 goto out_unlock;
1195 }1200 }