Skip to content

Commit

Permalink
[PATCH] device-mapper: Fix dm_swap_table error cases
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Alasdair G Kergon authored and Linus Torvalds committed Jul 12, 2005
1 parent c3cd4f6 commit 93c534a
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions drivers/md/dm.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

/*
Expand Down

0 comments on commit 93c534a

Please sign in to comment.