提交 2159102d 编写于 作者: Y Yufen Yu 提交者: Xie XiuQi

md: add mddev->pers to avoid potential NULL pointer dereference

commit ee37e62191a59d253fc916b9fc763deb777211e2 upstream.

When doing re-add, we need to ensure rdev->mddev->pers is not NULL,
which can avoid potential NULL pointer derefence in fallowing
add_bound_rdev().

Fixes: a6da4ef8 ("md: re-add a failed disk")
Cc: Xiao Ni <xni@redhat.com>
Cc: NeilBrown <neilb@suse.com>
Cc: <stable@vger.kernel.org> # 4.4+
Reviewed-by: NNeilBrown <neilb@suse.com>
Signed-off-by: NYufen Yu <yuyufen@huawei.com>
Signed-off-by: NSong Liu <songliubraving@fb.com>
Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
上级 59f7443d
...@@ -2860,8 +2860,10 @@ state_store(struct md_rdev *rdev, const char *buf, size_t len) ...@@ -2860,8 +2860,10 @@ state_store(struct md_rdev *rdev, const char *buf, size_t len)
err = 0; err = 0;
} }
} else if (cmd_match(buf, "re-add")) { } else if (cmd_match(buf, "re-add")) {
if (test_bit(Faulty, &rdev->flags) && (rdev->raid_disk == -1) && if (!rdev->mddev->pers)
rdev->saved_raid_disk >= 0) { err = -EINVAL;
else if (test_bit(Faulty, &rdev->flags) && (rdev->raid_disk == -1) &&
rdev->saved_raid_disk >= 0) {
/* clear_bit is performed _after_ all the devices /* clear_bit is performed _after_ all the devices
* have their local Faulty bit cleared. If any writes * have their local Faulty bit cleared. If any writes
* happen in the meantime in the local node, they * happen in the meantime in the local node, they
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册