From: Jun'ichi Nomura Date: Mon, 30 Oct 2006 21:23:45 +0000 (-0500) Subject: [PATCH] fix bd_claim_by_kobject error handling X-Git-Tag: v2.6.19-rc4~3 X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bcb55165d3d1ae3ec95807d118fd6d5956cd127b;p=linux-2.6 [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: Jun'ichi Nomura Signed-off-by: Linus Torvalds --- diff --git a/fs/block_dev.c b/fs/block_dev.c index 702b88cbd9..b54b0a1b7c 100644 --- a/fs/block_dev.c +++ b/fs/block_dev.c @@ -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);