From: Christoph Hellwig <[email protected]>

[ Upstream commit 2bd645b2d3f0bacadaa6037f067538e1cd4e42ef ]

bdget_disk needs to be paired with bdput to not leak a reference
on the block device inode.

Fixes: 08ba91ee6e2c ("nbd: Add the nbd NBD_DISCONNECT_ON_CLOSE config flag.")
Signed-off-by: Christoph Hellwig <[email protected]>
Reviewed-by: Josef Bacik <[email protected]>
Signed-off-by: Jens Axboe <[email protected]>
Signed-off-by: Sasha Levin <[email protected]>
---
 drivers/block/nbd.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c
index d76fca629c143..36c46fe078556 100644
--- a/drivers/block/nbd.c
+++ b/drivers/block/nbd.c
@@ -1517,6 +1517,7 @@ static void nbd_release(struct gendisk *disk, fmode_t 
mode)
        if (test_bit(NBD_RT_DISCONNECT_ON_CLOSE, &nbd->config->runtime_flags) &&
                        bdev->bd_openers == 0)
                nbd_disconnect_and_put(nbd);
+       bdput(bdev);
 
        nbd_config_put(nbd);
        nbd_put(nbd);
-- 
2.27.0



Reply via email to