Skip to content

Commit

Permalink
[PATCH] fix bd_claim_by_kobject error handling
Browse files Browse the repository at this point in the history
This fixes bd_claim_by_kobject to release bdev correctly in case that
bd_claim succeeds but following add_bd_holder fails.

Signed-off-by: Jun'ichi Nomura <j-nomura@ce.jp.nec.com>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
  • Loading branch information
Jun'ichi Nomura authored and Linus Torvalds committed Oct 31, 2006
1 parent a7aacdf commit bcb5516
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion fs/block_dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -751,8 +751,11 @@ static int bd_claim_by_kobject(struct block_device *bdev, void *holder,

mutex_lock_nested(&bdev->bd_mutex, BD_MUTEX_PARTITION);
res = bd_claim(bdev, holder);
if (res == 0)
if (res == 0) {
res = add_bd_holder(bdev, bo);
if (res)
bd_release(bdev);
}
if (res)
free_bd_holder(bo);
mutex_unlock(&bdev->bd_mutex);
Expand Down

0 comments on commit bcb5516

Please sign in to comment.