Commit bcb55165 authored by Jun'ichi Nomura's avatar Jun'ichi Nomura Committed by Linus Torvalds

[PATCH] fix bd_claim_by_kobject error handling

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: default avatarJun'ichi Nomura <j-nomura@ce.jp.nec.com>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent a7aacdf9
......@@ -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);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment