lkml.org 
[lkml]   [2009]   [Jun]   [21]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH] MD: md, fix lock imbalance
Date
Add unlock and put to one of fail paths in md_alloc.

Signed-off-by: Jiri Slaby <jirislaby@gmail.com>
---
drivers/md/md.c | 26 +++++++++++++++-----------
1 files changed, 15 insertions(+), 11 deletions(-)

diff --git a/drivers/md/md.c b/drivers/md/md.c
index 0f11fd1..6264933 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -3833,7 +3833,7 @@ static int md_alloc(dev_t dev, char *name)
int partitioned;
int shift;
int unit;
- int error;
+ int error, ret;

if (!mddev)
return -ENODEV;
@@ -3849,9 +3849,8 @@ static int md_alloc(dev_t dev, char *name)

mutex_lock(&disks_mutex);
if (mddev->gendisk) {
- mutex_unlock(&disks_mutex);
- mddev_put(mddev);
- return -EEXIST;
+ ret = -EEXIST;
+ goto unlock;
}

if (name) {
@@ -3864,16 +3863,16 @@ static int md_alloc(dev_t dev, char *name)
if (mddev2->gendisk &&
strcmp(mddev2->gendisk->disk_name, name) == 0) {
spin_unlock(&all_mddevs_lock);
- return -EEXIST;
+ ret = -EEXIST;
+ goto unlock;
}
spin_unlock(&all_mddevs_lock);
}

mddev->queue = blk_alloc_queue(GFP_KERNEL);
if (!mddev->queue) {
- mutex_unlock(&disks_mutex);
- mddev_put(mddev);
- return -ENOMEM;
+ ret = -ENOMEM;
+ goto unlock;
}
mddev->queue->queuedata = mddev;

@@ -3887,8 +3886,8 @@ static int md_alloc(dev_t dev, char *name)
mutex_unlock(&disks_mutex);
blk_cleanup_queue(mddev->queue);
mddev->queue = NULL;
- mddev_put(mddev);
- return -ENOMEM;
+ ret = -ENOMEM;
+ goto put;
}
disk->major = MAJOR(mddev->unit);
disk->first_minor = unit << shift;
@@ -3918,8 +3917,13 @@ static int md_alloc(dev_t dev, char *name)
kobject_uevent(&mddev->kobj, KOBJ_ADD);
mddev->sysfs_state = sysfs_get_dirent(mddev->kobj.sd, "array_state");
}
+ ret = 0;
+put:
mddev_put(mddev);
- return 0;
+ return ret;
+unlock:
+ mutex_unlock(&disks_mutex);
+ goto put;
}

static struct kobject *md_probe(dev_t dev, int *part, void *data)
--
1.6.3.2


\
 
 \ /
  Last update: 2009-06-22 00:03    [W:0.078 / U:0.676 seconds]
©2003-2017 Jasper Spaans. hosted at Digital OceanAdvertise on this site