Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 70c8d6d6 authored by Jan Kara's avatar Jan Kara Committed by Ritesh Harjani
Browse files

block: Make del_gendisk() safer for disks without queues



commit 165a5e22fafb "block: Move bdi_unregister() to del_gendisk()"
added disk->queue dereference to del_gendisk(). Although del_gendisk()
is not supposed to be called without disk->queue valid and
blk_unregister_queue() warns in that case, this change will make it oops
instead. Return to the old more robust behavior of just warning when
del_gendisk() gets called for gendisk with disk->queue being NULL.

Reported-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: default avatarJan Kara <jack@suse.cz>
Tested-by: default avatarOmar Sandoval <osandov@fb.com>
Signed-off-by: default avatarJens Axboe <axboe@fb.com>
Git-commit: 90f16fddcc2802726142b8386c65ccb89f044613
Git-repo: git://git.kernel.org/pub/scm/linux/kernel/git/axboe/linux-block.git


Change-Id: I5ae377b2ace64d7a133979e656beb0eba45abc09
Signed-off-by: default avatarRitesh Harjani <riteshh@codeaurora.org>
parent 9af69213
Loading
Loading
Loading
Loading
+10 −6
Original line number Diff line number Diff line
@@ -656,12 +656,16 @@ void del_gendisk(struct gendisk *disk)
	disk->flags &= ~GENHD_FL_UP;

	sysfs_remove_link(&disk_to_dev(disk)->kobj, "bdi");
	if (disk->queue) {
		/*
	 * Unregister bdi before releasing device numbers (as they can get
	 * reused and we'd get clashes in sysfs).
		 * Unregister bdi before releasing device numbers (as they can
		 * get reused and we'd get clashes in sysfs).
		 */
		bdi_unregister(&disk->queue->backing_dev_info);
		blk_unregister_queue(disk);
	} else {
		WARN_ON(1);
	}
	blk_unregister_region(disk_devt(disk), disk->minors);

	part_stat_set_all(&disk->part0, 0);