[PATCH] device-mapper: Fix dm_swap_table error cases

From: Alasdair G Kergon
Date: Fri Jul 08 2005 - 15:29:59 EST


Fix dm_swap_table() __bind error cases: a missing unlock, and EINVAL
preferable to EPERM.

Signed-Off-By: Alasdair G Kergon <agk@xxxxxxxxxx>
--- diff/drivers/md/dm.c 2005-07-08 19:21:37.000000000 +0100
+++ source/drivers/md/dm.c 2005-07-08 19:36:03.000000000 +0100
@@ -966,23 +966,20 @@
*/
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;
}

/*

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/