aboutsummaryrefslogtreecommitdiffstats
path: root/block/genhd.c
diff options
context:
space:
mode:
Diffstat (limited to 'block/genhd.c')
-rw-r--r--block/genhd.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/block/genhd.c b/block/genhd.c
index 94855a9717de..024fc3944fb5 100644
--- a/block/genhd.c
+++ b/block/genhd.c
@@ -612,6 +612,12 @@ void add_disk(struct gendisk *disk)
612 register_disk(disk); 612 register_disk(disk);
613 blk_register_queue(disk); 613 blk_register_queue(disk);
614 614
615 /*
616 * Take an extra ref on queue which will be put on disk_release()
617 * so that it sticks around as long as @disk is there.
618 */
619 WARN_ON_ONCE(blk_get_queue(disk->queue));
620
615 retval = sysfs_create_link(&disk_to_dev(disk)->kobj, &bdi->dev->kobj, 621 retval = sysfs_create_link(&disk_to_dev(disk)->kobj, &bdi->dev->kobj,
616 "bdi"); 622 "bdi");
617 WARN_ON(retval); 623 WARN_ON(retval);
@@ -1166,6 +1172,8 @@ static void disk_release(struct device *dev)
1166 disk_replace_part_tbl(disk, NULL); 1172 disk_replace_part_tbl(disk, NULL);
1167 free_part_stats(&disk->part0); 1173 free_part_stats(&disk->part0);
1168 free_part_info(&disk->part0); 1174 free_part_info(&disk->part0);
1175 if (disk->queue)
1176 blk_put_queue(disk->queue);
1169 kfree(disk); 1177 kfree(disk);
1170} 1178}
1171struct class block_class = { 1179struct class block_class = {