From 11e2ede0228ee0f81ccacd15894908c3bf241f73 Mon Sep 17 00:00:00 2001 From: Dan Williams Date: Wed, 30 Apr 2008 00:52:32 -0700 Subject: [PATCH] md: prevent duplicates in bind_rdev_to_array Found when trying to reassemble an active externally managed array. Without this check we hit the more noisy "sysfs duplicate" warning in the later call to kobject_add. Signed-off-by: Dan Williams Signed-off-by: Neil Brown Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/md/md.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/md/md.c b/drivers/md/md.c index 75a3f483522d..bec00b201a73 100644 --- a/drivers/md/md.c +++ b/drivers/md/md.c @@ -1370,6 +1370,11 @@ static int bind_rdev_to_array(mdk_rdev_t * rdev, mddev_t * mddev) MD_BUG(); return -EINVAL; } + + /* prevent duplicates */ + if (find_rdev(mddev, rdev->bdev->bd_dev)) + return -EEXIST; + /* make sure rdev->size exceeds mddev->size */ if (rdev->size && (mddev->size == 0 || rdev->size < mddev->size)) { if (mddev->pers) { -- 2.20.1