From 46622b98863b716b4187520e530ca12a55809a03 Mon Sep 17 00:00:00 2001 From: Pawel Baldysiak Date: Wed, 19 Jun 2019 16:20:18 +0800 Subject: [PATCH] md: return -ENODEV if rdev has no mddev assigned mainline inclusion from mainline-5.2-rc1 commit c42d3240990814eec1e4b2b93fa0487fc4873aed category: bugfix bugzilla: 16584 CVE: NA --------------------------- Mdadm expects that setting drive as faulty will fail with -EBUSY only if this operation will cause RAID to be failed. If this happens, it will try to stop the array. Currently -EBUSY might also be returned if rdev is in the middle of the removal process - for example there is a race with mdmon that already requested the drive to be failed/removed. If rdev does not contain mddev, return -ENODEV instead, so the caller can distinguish between those two cases and behave accordingly. Reviewed-by: NeilBrown Signed-off-by: Pawel Baldysiak Signed-off-by: Song Liu Signed-off-by: Yufen Yu Reviewed-by: Hou Tao Signed-off-by: Yang Yingliang --- 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 759b91d2b537..5b96e3e88759 100644 --- a/drivers/md/md.c +++ b/drivers/md/md.c @@ -3391,10 +3391,10 @@ rdev_attr_store(struct kobject *kobj, struct attribute *attr, return -EIO; if (!capable(CAP_SYS_ADMIN)) return -EACCES; - rv = mddev ? mddev_lock(mddev): -EBUSY; + rv = mddev ? mddev_lock(mddev) : -ENODEV; if (!rv) { if (rdev->mddev == NULL) - rv = -EBUSY; + rv = -ENODEV; else rv = entry->store(rdev, page, length); mddev_unlock(mddev); -- GitLab