浏览代码

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>
NeilBrown 16 年之前
父节点
当前提交
1ec22eb2b4
共有 1 个文件被更改,包括 2 次插入0 次删除
  1. 2 0
      drivers/md/md.c

+ 2 - 0
drivers/md/md.c

@@ -3862,6 +3862,8 @@ static int md_alloc(dev_t dev, char *name)
 			if (mddev2->gendisk &&
 			if (mddev2->gendisk &&
 			    strcmp(mddev2->gendisk->disk_name, name) == 0) {
 			    strcmp(mddev2->gendisk->disk_name, name) == 0) {
 				spin_unlock(&all_mddevs_lock);
 				spin_unlock(&all_mddevs_lock);
+				mutex_unlock(&disks_mutex);
+				mddev_put(mddev);
 				return -EEXIST;
 				return -EEXIST;
 			}
 			}
 		spin_unlock(&all_mddevs_lock);
 		spin_unlock(&all_mddevs_lock);