MD: fix a null dereference
authorShaohua Li <shli@fb.com>
Fri, 23 Jun 2017 16:19:49 +0000 (09:19 -0700)
committerShaohua Li <shli@fb.com>
Fri, 23 Jun 2017 16:19:49 +0000 (09:19 -0700)
rdev->mddev could be null in start time.

Reported-by: Ming Lei <ming.lei@redhat.com>
Fix: 5a85071c2cbc(md: use a separate bio_set for synchronous IO.)
Cc: NeilBrown <neilb@suse.com>
Signed-off-by: Shaohua Li <shli@fb.com>
drivers/md/md.c

index 65ad837aeb5435516ac78260a667659eaa007aae..092b48f8095e828cb387f805ea98150a32c5b674 100644 (file)
@@ -205,7 +205,7 @@ EXPORT_SYMBOL_GPL(bio_alloc_mddev);
 
 static struct bio *md_bio_alloc_sync(struct mddev *mddev)
 {
-       if (!mddev->sync_set)
+       if (!mddev || !mddev->sync_set)
                return bio_alloc(GFP_NOIO, 1);
 
        return bio_alloc_bioset(GFP_NOIO, 1, mddev->sync_set);