]> err.no Git - linux-2.6/commitdiff
[PATCH] fix bd_claim_by_kobject error handling
authorJun'ichi Nomura <j-nomura@ce.jp.nec.com>
Mon, 30 Oct 2006 21:23:45 +0000 (16:23 -0500)
committerLinus Torvalds <torvalds@g5.osdl.org>
Tue, 31 Oct 2006 03:29:41 +0000 (19:29 -0800)
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>
fs/block_dev.c

index 702b88cbd91d2dc91eb81cb41784574b89df4edd..b54b0a1b7c68589c0dd6d1b00f9e103db1673e19 100644 (file)
@@ -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);