]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/commitdiff
[PATCH] device-mapper: Fix dm_swap_table error cases
authorAlasdair G Kergon <agk@redhat.com>
Tue, 12 Jul 2005 22:53:05 +0000 (15:53 -0700)
committerLinus Torvalds <torvalds@g5.osdl.org>
Tue, 12 Jul 2005 23:19:11 +0000 (16:19 -0700)
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>
drivers/md/dm.c

index bb3ad79c14d7deeabce18c00577f8add278ab51b..54fabbf06678d838407a11e203e2b2c7fea6fb33 100644 (file)
@@ -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;
 }
 
 /*