From: Jiri Slaby <jirislaby@gmail.com>
To: neilb@suse.de
Cc: linux-raid@vger.kernel.org, linux-kernel@vger.kernel.org,
Jiri Slaby <jirislaby@gmail.com>
Subject: [PATCH] MD: md, fix lock imbalance
Date: Sun, 21 Jun 2009 23:59:36 +0200 [thread overview]
Message-ID: <1245621576-27066-1-git-send-email-jirislaby@gmail.com> (raw)
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
next reply other threads:[~2009-06-21 21:59 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-06-21 21:59 Jiri Slaby [this message]
2009-06-22 12:25 ` Andre Noll
2009-07-01 1:46 ` Neil Brown
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1245621576-27066-1-git-send-email-jirislaby@gmail.com \
--to=jirislaby@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-raid@vger.kernel.org \
--cc=neilb@suse.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®