summaryrefslogtreecommitdiffstats
path: root/drivers/md/md.c
diff options
context:
space:
mode:
authorNeilBrown <neilb@suse.de>2009-07-01 04:27:21 +0200
committerNeilBrown <neilb@suse.de>2009-07-01 04:27:21 +0200
commit1ec22eb2b4a2e1a763106bce36b11c02eaa84e61 (patch)
tree2aa6e6539342a28263417f6a2f2551d541e9ead9 /drivers/md/md.c
parentmd: avoid dereferencing NULL pointer when accessing suspend_* sysfs attributes. (diff)
downloadlinux-1ec22eb2b4a2e1a763106bce36b11c02eaa84e61.tar.xz
linux-1ec22eb2b4a2e1a763106bce36b11c02eaa84e61.zip
md: fix error path when duplicate name is found on md device creation.
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. Cc: stable@kernel.org Found-by: Jiri Slaby <jirislaby@gmail.com> Signed-off-by: NeilBrown <neilb@suse.de>
Diffstat (limited to 'drivers/md/md.c')
-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 2166af8a7654..58bee2366ea8 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -3862,6 +3862,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);