From: Dmitry Monakhov <dmonakhov@openvz.org>
To: linux-kernel@vger.kernel.org
Cc: device-mapper development <dm-devel@redhat.com>
Subject: [PATCH 3/8] dm: dm-raid1 resource leaks fixes.
Date: Tue, 24 Jul 2007 12:57:11 +0400 [thread overview]
Message-ID: <20070724085711.GC16507@dnb.sw.ru> (raw)
In-Reply-To: <20070724085106.GD20538@dnb.sw.ru>
- Add missing 'dm_io_client_destroy' to alloc_context error path.
- Reorganize mirror constructor error path in order to prevent
workqueue leakage.
Signed-off-by: Dmitry Monakhov <dmonakhov@openvz.org>
---
drivers/md/dm-raid1.c | 28 +++++++++++++++-------------
1 files changed, 15 insertions(+), 13 deletions(-)
diff --git a/drivers/md/dm-raid1.c b/drivers/md/dm-raid1.c
index 144071e..58b9f1a 100644
--- a/drivers/md/dm-raid1.c
+++ b/drivers/md/dm-raid1.c
@@ -974,6 +974,7 @@ static struct mirror_set *alloc_context(unsigned int nr_mirrors,
if (rh_init(&ms->rh, ms, dl, region_size, ms->nr_regions)) {
ti->error = "Error creating dirty region hash";
+ dm_io_client_destroy(ms->io_client);
kfree(ms);
return NULL;
}
@@ -1163,16 +1164,14 @@ static int mirror_ctr(struct dm_target *ti, unsigned int argc, char **argv)
ms->kmirrord_wq = create_singlethread_workqueue("kmirrord");
if (!ms->kmirrord_wq) {
DMERR("couldn't start kmirrord");
- free_context(ms, ti, m);
- return -ENOMEM;
+ r = -ENOMEM;
+ goto out_free_context;
}
INIT_WORK(&ms->kmirrord_work, do_mirror);
r = parse_features(ms, argc, argv, &args_used);
- if (r) {
- free_context(ms, ti, ms->nr_mirrors);
- return r;
- }
+ if (r)
+ goto out_destroy_wq;
argv += args_used;
argc -= args_used;
@@ -1188,19 +1187,22 @@ static int mirror_ctr(struct dm_target *ti, unsigned int argc, char **argv)
if (argc) {
ti->error = "Too many mirror arguments";
- free_context(ms, ti, ms->nr_mirrors);
- return -EINVAL;
+ r = -EINVAL;
+ goto out_destroy_wq;
}
r = kcopyd_client_create(DM_IO_PAGES, &ms->kcopyd_client);
- if (r) {
- destroy_workqueue(ms->kmirrord_wq);
- free_context(ms, ti, ms->nr_mirrors);
- return r;
- }
+ if (r)
+ goto out_destroy_wq;
wake(ms);
return 0;
+
+out_destroy_wq:
+ destroy_workqueue(ms->kmirrord_wq);
+out_free_context:
+ free_context(ms, ti, ms->nr_mirrors);
+ return r;
}
static void mirror_dtr(struct dm_target *ti)
--
1.5.2.2
next prev parent reply other threads:[~2007-07-24 8:56 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-07-24 8:51 dm: device mapper code cleanup Dmitry Monakhov
2007-07-24 8:55 ` [PATCH 1/8] dm: Add missing 'kfree' to dm-crypt target constructor Dmitry Monakhov
2007-07-24 8:56 ` [PATCH 2/8] dm: Fix workqueue leak for raid5 Dmitry Monakhov
2007-07-24 22:27 ` Dan Williams
2007-07-24 8:57 ` Dmitry Monakhov [this message]
2007-07-24 8:58 ` [PATCH 4/8] dm:dm-hw-handler.c Convert kmalloc + memset to kzalloc Dmitry Monakhov
2007-07-24 8:58 ` [PATCH 5/8] dm: dm-table.c " Dmitry Monakhov
2007-07-24 8:58 ` [PATCH 6/8] dm: dm-emc.c " Dmitry Monakhov
2007-07-24 8:59 ` [PATCH 7/8] dm: dm-path-selector.c " Dmitry Monakhov
2007-07-24 8:59 ` [PATCH 8/8] dm: dm-target.c " Dmitry Monakhov
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=20070724085711.GC16507@dnb.sw.ru \
--to=dmonakhov@openvz.org \
--cc=dm-devel@redhat.com \
--cc=linux-kernel@vger.kernel.org \
/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