summaryrefslogtreecommitdiff
path: root/drivers/md/dm.c
diff options
context:
space:
mode:
authorAlasdair G Kergon <agk@redhat.com>2005-07-12 15:53:05 -0700
committerLinus Torvalds <torvalds@g5.osdl.org>2005-07-12 16:19:11 -0700
commit93c534aefb906824d71ea779ed0c7f1573843f4e (patch)
tree9deaabe380491885f7a312648e222f266cdf064f /drivers/md/dm.c
parentc3cd4f6b275da0f594797b73f721a4185335478f (diff)
downloadlwn-93c534aefb906824d71ea779ed0c7f1573843f4e.tar.gz
lwn-93c534aefb906824d71ea779ed0c7f1573843f4e.zip
[PATCH] device-mapper: Fix dm_swap_table error cases
Fix dm_swap_table() __bind error cases: a missing unlock, and EINVAL preferable to EPERM. Signed-off-by: Alasdair G Kergon <agk@redhat.com> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'drivers/md/dm.c')
-rw-r--r--drivers/md/dm.c13
1 files changed, 5 insertions, 8 deletions
diff --git a/drivers/md/dm.c b/drivers/md/dm.c
index bb3ad79c14d7..54fabbf06678 100644
--- a/drivers/md/dm.c
+++ b/drivers/md/dm.c
@@ -966,23 +966,20 @@ static void __flush_deferred_io(struct mapped_device *md, struct bio *c)
*/
int dm_swap_table(struct mapped_device *md, struct dm_table *table)
{
- int r;
+ int r = -EINVAL;
down_write(&md->lock);
/* device must be suspended */
- if (!test_bit(DMF_SUSPENDED, &md->flags)) {
- up_write(&md->lock);
- return -EPERM;
- }
+ if (!test_bit(DMF_SUSPENDED, &md->flags))
+ goto out;
__unbind(md);
r = __bind(md, table);
- if (r)
- return r;
+out:
up_write(&md->lock);
- return 0;
+ return r;
}
/*