[Devel,RHEL7,COMMIT] ploop: drop bdev refcounter on freeze_bdev() failure

Submitted by Konstantin Khorenko on Aug. 20, 2016, 9:36 a.m.

Details

Message ID 201608200936.u7K9aNoA000663@finist_cl7.x64_64.work.ct
State New
Series "ploop: add support for dm-crypted ploops"
Headers show

Commit Message

Konstantin Khorenko Aug. 20, 2016, 9:36 a.m.
The commit is pushed to "branch-rh7-3.10.0-327.28.2.vz7.17.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-327.28.2.vz7.17.2
------>
commit 5ec893951ac21ab8d10b0b19e3d6edc45dff4b3a
Author: Andrey Ryabinin <aryabinin@virtuozzo.com>
Date:   Sat Aug 20 13:36:22 2016 +0400

    ploop: drop bdev refcounter on freeze_bdev() failure
    
    If freeze_bdev() called in find_and_freeze_bdev() fails we should
    drop a reference counter grabbed by bdget_disk() call.
    
    Signed-off-by: Andrey Ryabinin <aryabinin@virtuozzo.com>
    Acked-by: Maxim Patlasov <mpatlasov@virtuozzo.com>
---
 drivers/block/ploop/dev.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

Patch hide | download patch | download mbox

diff --git a/drivers/block/ploop/dev.c b/drivers/block/ploop/dev.c
index 83b0e32..453d36e 100644
--- a/drivers/block/ploop/dev.c
+++ b/drivers/block/ploop/dev.c
@@ -3339,7 +3339,10 @@  static struct super_block *find_and_freeze_bdev(struct gendisk *disk,
 		bdev = NULL;
 	}
 
-	*bdev_pp = bdev;
+	if (IS_ERR(sb))
+		bdput(bdev);
+	else
+		*bdev_pp = bdev;
 	return sb;
 }