summaryrefslogtreecommitdiff
path: root/drivers/block
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2020-11-09 18:30:59 +0100
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2020-11-18 19:18:47 +0100
commitd9f4534a9a286877ae29e15b5f9ba8ecb7370924 (patch)
tree765a6f89d9b55743b0d9ed166b6d794de8d4ee14 /drivers/block
parent5818925f87d33b9a77e3f4d78a47f0f823f221cc (diff)
nbd: fix a block_device refcount leak in nbd_release
[ 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 <hch@lst.de> Reviewed-by: Josef Bacik <josef@toxicpanda.com> Signed-off-by: Jens Axboe <axboe@kernel.dk> Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'drivers/block')
-rw-r--r--drivers/block/nbd.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c
index 706115ecd9be..517318bb350c 100644
--- a/drivers/block/nbd.c
+++ b/drivers/block/nbd.c
@@ -1448,6 +1448,7 @@ static void nbd_release(struct gendisk *disk, fmode_t mode)
if (test_bit(NBD_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);