block: add WARN_ON if bdi register fail

device_add_disk need do more safety error handle, so this patch just
add WARN_ON.

Reviewed-by: Jan Kara <jack@suse.cz>
Signed-off-by: weiping zhang <zhangweiping@didichuxing.com>

Adapted for current series by me.
Signed-off-by: Jens Axboe <axboe@kernel.dk>
This commit is contained in:
weiping zhang 2017-10-31 18:38:59 +08:00 committed by Jens Axboe
parent a0747a859e
commit 3a92168bc8
1 changed files with 5 additions and 2 deletions

View File

@ -671,10 +671,13 @@ void device_add_disk(struct device *parent, struct gendisk *disk)
disk->flags |= GENHD_FL_SUPPRESS_PARTITION_INFO; disk->flags |= GENHD_FL_SUPPRESS_PARTITION_INFO;
disk->flags |= GENHD_FL_NO_PART_SCAN; disk->flags |= GENHD_FL_NO_PART_SCAN;
} else { } else {
int ret;
/* Register BDI before referencing it from bdev */ /* Register BDI before referencing it from bdev */
disk_to_dev(disk)->devt = devt; disk_to_dev(disk)->devt = devt;
bdi_register_owner(disk->queue->backing_dev_info, ret = bdi_register_owner(disk->queue->backing_dev_info,
disk_to_dev(disk)); disk_to_dev(disk));
WARN_ON(ret);
blk_register_region(disk_devt(disk), disk->minors, NULL, blk_register_region(disk_devt(disk), disk->minors, NULL,
exact_match, exact_lock, disk); exact_match, exact_lock, disk);
} }