[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>
This commit is contained in:
Alasdair G Kergon 2005-07-12 15:53:05 -07:00 коммит произвёл Linus Torvalds
Родитель c3cd4f6b27
Коммит 93c534aefb
1 изменённых файлов: 5 добавлений и 8 удалений

Просмотреть файл

@ -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 dm_swap_table(struct mapped_device *md, struct dm_table *table)
{ {
int r; int r = -EINVAL;
down_write(&md->lock); down_write(&md->lock);
/* device must be suspended */ /* device must be suspended */
if (!test_bit(DMF_SUSPENDED, &md->flags)) { if (!test_bit(DMF_SUSPENDED, &md->flags))
up_write(&md->lock); goto out;
return -EPERM;
}
__unbind(md); __unbind(md);
r = __bind(md, table); r = __bind(md, table);
if (r)
return r;
out:
up_write(&md->lock); up_write(&md->lock);
return 0; return r;
} }
/* /*