Commit 4d7c1d3f authored by zhengbin's avatar zhengbin Committed by Jens Axboe

block: fix NULL pointer dereference in register_disk

If __device_add_disk-->bdi_register_owner-->bdi_register-->
bdi_register_va-->device_create_vargs fails, bdi->dev is still
NULL, __device_add_disk-->register_disk will visit bdi->dev->kobj.
This patch fixes that.
Signed-off-by: default avatarzhengbin <zhengbin13@huawei.com>
Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent dce30ca9
...@@ -655,10 +655,12 @@ static void register_disk(struct device *parent, struct gendisk *disk, ...@@ -655,10 +655,12 @@ static void register_disk(struct device *parent, struct gendisk *disk,
kobject_uevent(&part_to_dev(part)->kobj, KOBJ_ADD); kobject_uevent(&part_to_dev(part)->kobj, KOBJ_ADD);
disk_part_iter_exit(&piter); disk_part_iter_exit(&piter);
err = sysfs_create_link(&ddev->kobj, if (disk->queue->backing_dev_info->dev) {
&disk->queue->backing_dev_info->dev->kobj, err = sysfs_create_link(&ddev->kobj,
"bdi"); &disk->queue->backing_dev_info->dev->kobj,
WARN_ON(err); "bdi");
WARN_ON(err);
}
} }
/** /**
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment