[Devel,rh7,v3,1/4] ploop: drop bdev refcounter on freeze_bdev() failure

Submitted by Andrey Ryabinin on Aug. 19, 2016, 1 p.m.

Details

Message ID 1471611621-6838-1-git-send-email-aryabinin@virtuozzo.com
State New
Series "ploop: add support for dm-crypted ploops"
Headers show

Commit Message

Andrey Ryabinin Aug. 19, 2016, 1 p.m.
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;
 }
 

Comments

Maxim Patlasov Aug. 19, 2016, 5:17 p.m.
Acked-by: Maxim Patlasov <mpatlasov@virtuozzo.com>


On 08/19/2016 06:00 AM, Andrey Ryabinin wrote:
> 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(-)
>
> 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;
>   }
>