Skip to content

Commit

Permalink
block: add WARN_ON if bdi register fail
Browse files Browse the repository at this point in the history
device_add_disk need do more safety error handle, so this patch just
add WARN_ON.

Reviewed-by: Jan Kara <[email protected]>
Signed-off-by: weiping zhang <[email protected]>

Adapted for current series by me.
Signed-off-by: Jens Axboe <[email protected]>
  • Loading branch information
weiping zhang authored and axboe committed Nov 19, 2017
1 parent a0747a8 commit 3a92168
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions block/genhd.c
Original file line number Diff line number Diff line change
Expand Up @@ -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_NO_PART_SCAN;
} else {
int ret;

/* Register BDI before referencing it from bdev */
disk_to_dev(disk)->devt = devt;
bdi_register_owner(disk->queue->backing_dev_info,
disk_to_dev(disk));
ret = bdi_register_owner(disk->queue->backing_dev_info,
disk_to_dev(disk));
WARN_ON(ret);
blk_register_region(disk_devt(disk), disk->minors, NULL,
exact_match, exact_lock, disk);
}
Expand Down

0 comments on commit 3a92168

Please sign in to comment.