aboutsummaryrefslogtreecommitdiff
path: root/block
diff options
context:
space:
mode:
authorzhengbin <zhengbin13@huawei.com>2019-02-20 21:27:05 +0800
committerJens Axboe <axboe@kernel.dk>2019-02-28 14:01:36 -0700
commit4d7c1d3fd7c7eda7dea351f071945e843a46c145 (patch)
treeee56665588e6be4257fd7ac2d787e00ad6f2bb7a /block
parentdce30ca9e3b676fb288c33c1f4725a0621361185 (diff)
downloadlinux-stericsson-4d7c1d3fd7c7eda7dea351f071945e843a46c145.tar.gz
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: zhengbin <zhengbin13@huawei.com> Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'block')
-rw-r--r--block/genhd.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/block/genhd.c b/block/genhd.c
index 1dd8fd6613b8..78b82d26aa9c 100644
--- a/block/genhd.c
+++ b/block/genhd.c
@@ -655,10 +655,12 @@ exit:
kobject_uevent(&part_to_dev(part)->kobj, KOBJ_ADD);
disk_part_iter_exit(&piter);
- err = sysfs_create_link(&ddev->kobj,
- &disk->queue->backing_dev_info->dev->kobj,
- "bdi");
- WARN_ON(err);
+ if (disk->queue->backing_dev_info->dev) {
+ err = sysfs_create_link(&ddev->kobj,
+ &disk->queue->backing_dev_info->dev->kobj,
+ "bdi");
+ WARN_ON(err);
+ }
}
/**