@@ -658,6 +658,7 @@ void del_gendisk(struct gendisk *disk)
disk->flags &= ~GENHD_FL_UP;
sysfs_remove_link(&disk_to_dev(disk)->kobj, "bdi");
+ bdi_unregister(&disk->queue->backing_dev_info);
blk_unregister_queue(disk);
blk_unregister_region(disk_devt(disk), disk->minors);
@@ -853,12 +853,12 @@ static void bdi_remove_from_list(struct backing_dev_info *bdi)
void bdi_unregister(struct backing_dev_info *bdi)
{
- /* make sure nobody finds us on the bdi_list anymore */
- bdi_remove_from_list(bdi);
- wb_shutdown(&bdi->wb);
- cgwb_bdi_destroy(bdi);
-
if (bdi->dev) {
+ /* make sure nobody finds us on the bdi_list anymore */
+ bdi_remove_from_list(bdi);
+ wb_shutdown(&bdi->wb);
+ cgwb_bdi_destroy(bdi);
+
bdi_debug_unregister(bdi);
device_unregister(bdi->dev);
bdi->dev = NULL;