Commit 2bd645b2 authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Jens Axboe

nbd: fix a block_device refcount leak in nbd_release

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

Fixes: 08ba91ee ("nbd: Add the nbd NBD_DISCONNECT_ON_CLOSE config flag.")
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatarJosef Bacik <josef@toxicpanda.com>
Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent b5214c60
...@@ -1518,6 +1518,7 @@ static void nbd_release(struct gendisk *disk, fmode_t mode) ...@@ -1518,6 +1518,7 @@ static void nbd_release(struct gendisk *disk, fmode_t mode)
if (test_bit(NBD_RT_DISCONNECT_ON_CLOSE, &nbd->config->runtime_flags) && if (test_bit(NBD_RT_DISCONNECT_ON_CLOSE, &nbd->config->runtime_flags) &&
bdev->bd_openers == 0) bdev->bd_openers == 0)
nbd_disconnect_and_put(nbd); nbd_disconnect_and_put(nbd);
bdput(bdev);
nbd_config_put(nbd); nbd_config_put(nbd);
nbd_put(nbd); nbd_put(nbd);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment