summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNeilBrown <neilb@suse.de>2009-07-01 12:27:21 +1000
committerGreg Kroah-Hartman <gregkh@suse.de>2009-07-19 20:38:53 -0700
commit042128a85db99144c34a448c75d952cda8b6c19b (patch)
treed18f52c6a6bb31b9a7c74397b161ea6c7cd42fad
parent5de149123be72b438c5651ac8ca53223ca05a714 (diff)
md: fix error path when duplicate name is found on md device creation.
commit 1ec22eb2b4a2e1a763106bce36b11c02eaa84e61 upstream. When an md device is created by name (rather than number) we need to check that the name is not already in use. If this check finds a duplicate, we return an error without dropping the lock or freeing the newly create mddev. This patch fixes that. Found-by: Jiri Slaby <jirislaby@gmail.com> Signed-off-by: NeilBrown <neilb@suse.de> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
-rw-r--r--drivers/md/md.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/drivers/md/md.c b/drivers/md/md.c
index 641b211fe3fe..42d4eb8acbc0 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -3876,6 +3876,8 @@ static int md_alloc(dev_t dev, char *name)
if (mddev2->gendisk &&
strcmp(mddev2->gendisk->disk_name, name) == 0) {
spin_unlock(&all_mddevs_lock);
+ mutex_unlock(&disks_mutex);
+ mddev_put(mddev);
return -EEXIST;
}
spin_unlock(&all_mddevs_lock);