summaryrefslogtreecommitdiffstats
path: root/drivers/md
diff options
context:
space:
mode:
authorShaohua Li <shli@fb.com>2016-07-28 09:06:34 -0700
committerShaohua Li <shli@fb.com>2016-07-28 09:06:34 -0700
commit5d8817833c7609c24da9a92f71c53caa9c1424eb (patch)
tree4dbcce4eb6356405d66decd96f12c2c6fcc1d464 /drivers/md
parent0e5313e2d4ef93bdf6c22dad647d28635b86472a (diff)
downloadlinux-5d8817833c7609c24da9a92f71c53caa9c1424eb.tar.bz2
MD: fix null pointer deference
The md device might not have personality (for example, ddf raid array). The issue is introduced by 8430e7e0af9a15(md: disconnect device from personality before trying to remove it) Reported-by: kernel test robot <xiaolong.ye@intel.com> Signed-off-by: Shaohua Li <shli@fb.com>
Diffstat (limited to 'drivers/md')
-rw-r--r--drivers/md/md.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/drivers/md/md.c b/drivers/md/md.c
index f77cad854044..c059f17b44d2 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -2595,8 +2595,10 @@ state_store(struct md_rdev *rdev, const char *buf, size_t len)
else
err = -EBUSY;
} else if (cmd_match(buf, "remove")) {
- clear_bit(Blocked, &rdev->flags);
- remove_and_add_spares(rdev->mddev, rdev);
+ if (rdev->mddev->pers) {
+ clear_bit(Blocked, &rdev->flags);
+ remove_and_add_spares(rdev->mddev, rdev);
+ }
if (rdev->raid_disk >= 0)
err = -EBUSY;
else {