Skip to content

Commit

Permalink
md: fix error path when duplicate name is found on md device creation.
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
NeilBrown committed Jul 1, 2009
1 parent b8d966e commit 1ec22eb
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions drivers/md/md.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 1ec22eb

Please sign in to comment.