]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
md: fix error path when duplicate name is found on md device creation.
authorNeilBrown <neilb@suse.de>
Wed, 1 Jul 2009 02:27:21 +0000 (12:27 +1000)
committerGreg Kroah-Hartman <gregkh@suse.de>
Mon, 20 Jul 2009 03:38:53 +0000 (20:38 -0700)
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>
drivers/md/md.c

index 641b211fe3feb33e15cb1159e3a76ca26b90c124..42d4eb8acbc0ed511f03fcc40c56697a3836b0c3 100644 (file)
@@ -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);