Merge tag 'block-6.13-20241228' of git://git.kernel.dk/linux

Pull block fix from Jens Axboe:
"Just a single fix for ublk setup error handling"

* tag 'block-6.13-20241228' of git://git.kernel.dk/linux:
ublk: detach gendisk from ublk device if add_disk() fails

+17 -9
+17 -9
drivers/block/ublk_drv.c
··· 1618 1618 blk_mq_kick_requeue_list(ub->ub_disk->queue); 1619 1619 } 1620 1620 1621 + static struct gendisk *ublk_detach_disk(struct ublk_device *ub) 1622 + { 1623 + struct gendisk *disk; 1624 + 1625 + /* Sync with ublk_abort_queue() by holding the lock */ 1626 + spin_lock(&ub->lock); 1627 + disk = ub->ub_disk; 1628 + ub->dev_info.state = UBLK_S_DEV_DEAD; 1629 + ub->dev_info.ublksrv_pid = -1; 1630 + ub->ub_disk = NULL; 1631 + spin_unlock(&ub->lock); 1632 + 1633 + return disk; 1634 + } 1635 + 1621 1636 static void ublk_stop_dev(struct ublk_device *ub) 1622 1637 { 1623 1638 struct gendisk *disk; ··· 1646 1631 ublk_unquiesce_dev(ub); 1647 1632 } 1648 1633 del_gendisk(ub->ub_disk); 1649 - 1650 - /* Sync with ublk_abort_queue() by holding the lock */ 1651 - spin_lock(&ub->lock); 1652 - disk = ub->ub_disk; 1653 - ub->dev_info.state = UBLK_S_DEV_DEAD; 1654 - ub->dev_info.ublksrv_pid = -1; 1655 - ub->ub_disk = NULL; 1656 - spin_unlock(&ub->lock); 1634 + disk = ublk_detach_disk(ub); 1657 1635 put_disk(disk); 1658 1636 unlock: 1659 1637 mutex_unlock(&ub->mutex); ··· 2344 2336 2345 2337 out_put_cdev: 2346 2338 if (ret) { 2347 - ub->dev_info.state = UBLK_S_DEV_DEAD; 2339 + ublk_detach_disk(ub); 2348 2340 ublk_put_device(ub); 2349 2341 } 2350 2342 if (ret)