md: raid1: check rdev before reference in raid1_sync_request func
authorZhiqiang Liu <liuzhiqiang26@huawei.com>
Tue, 10 Dec 2019 02:42:25 +0000 (10:42 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 9 Jan 2020 09:17:52 +0000 (10:17 +0100)
[ Upstream commit 028288df635f5a9addd48ac4677b720192747944 ]

In raid1_sync_request func, rdev should be checked before reference.

Signed-off-by: Zhiqiang Liu <liuzhiqiang26@huawei.com>
Signed-off-by: Song Liu <songliubraving@fb.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/md/raid1.c

index f46ac9db9edb2b40dd7709164dd535b4968600d6..0a9d623b13c27d6a7b9d458045a8df925cbdab6c 100644 (file)
@@ -2749,7 +2749,7 @@ static sector_t raid1_sync_request(struct mddev *mddev, sector_t sector_nr,
                                write_targets++;
                        }
                }
-               if (bio->bi_end_io) {
+               if (rdev && bio->bi_end_io) {
                        atomic_inc(&rdev->nr_pending);
                        bio->bi_iter.bi_sector = sector_nr + rdev->data_offset;
                        bio_set_dev(bio, rdev->bdev);