<html>
  <head>
    <meta content="text/html; charset=windows-1252"
      http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    <p>Acked-by: Maxim Patlasov <a class="moz-txt-link-rfc2396E"
        href="mailto:mpatlasov@virtuozzo.com">&lt;mpatlasov@virtuozzo.com&gt;</a></p>
    <br>
    <div class="moz-cite-prefix">On 08/18/2016 09:51 AM, Andrey Ryabinin
      wrote:<br>
    </div>
    <blockquote
      cite="mid:1471539077-9862-1-git-send-email-aryabinin@virtuozzo.com"
      type="cite">
      <pre wrap="">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 <a class="moz-txt-link-rfc2396E" href="mailto:aryabinin@virtuozzo.com">&lt;aryabinin@virtuozzo.com&gt;</a>
---
 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;
 }
 
</pre>
    </blockquote>
    <br>
  </body>
</html>