We add rdev->mddev->pers to avoid potential NULL pointer derefence in fallowing add_bound_rdev(). Cc: Xiao Ni <xni@xxxxxxxxxx> Cc: NeilBrown <neilb@xxxxxxxx> Signed-off-by: Yufen Yu <yuyufen@xxxxxxxxxx> --- drivers/md/md.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/md/md.c b/drivers/md/md.c index 875b29ba5926..96cdad28a0d2 100644 --- a/drivers/md/md.c +++ b/drivers/md/md.c @@ -2859,8 +2859,8 @@ state_store(struct md_rdev *rdev, const char *buf, size_t len) err = 0; } } else if (cmd_match(buf, "re-add")) { - if (test_bit(Faulty, &rdev->flags) && (rdev->raid_disk == -1) && - rdev->saved_raid_disk >= 0) { + if (rdev->mddev->pers && test_bit(Faulty, &rdev->flags) && + (rdev->raid_disk == -1) && rdev->saved_raid_disk >= 0) { /* clear_bit is performed _after_ all the devices * have their local Faulty bit cleared. If any writes * happen in the meantime in the local node, they -- 2.16.2.dirty