Skip to content

Commit

Permalink
nbd: fix a block_device refcount leak in nbd_release
Browse files Browse the repository at this point in the history
bdget_disk needs to be paired with bdput to not leak a reference
on the block device inode.

Fixes: 08ba91e ("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>
  • Loading branch information
Christoph Hellwig authored and axboe committed Nov 10, 2020
1 parent b5214c6 commit 2bd645b
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions drivers/block/nbd.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) &&
bdev->bd_openers == 0)
nbd_disconnect_and_put(nbd);
bdput(bdev);

nbd_config_put(nbd);
nbd_put(nbd);
Expand Down

0 comments on commit 2bd645b

Please sign in to comment.