diff mbox series

block: fix leaking minors of hidden disks

Message ID 20221007193234.3958465-1-kbusch@meta.com (mailing list archive)
State New, archived
Headers show
Series block: fix leaking minors of hidden disks | expand

Commit Message

Keith Busch Oct. 7, 2022, 7:32 p.m. UTC
From: Keith Busch <kbusch@kernel.org>

The major/minor of a hidden gendisk is not propagated to the block
device. This is required to suppress it from being visible. For these
disks, we need to handle freeing the dynamic minor directly when it's
released since bdev_free_inode() won't be able to.

Cc: Christoph Hellwig <hch@lst.de>
Reported-by: Daniel Wagner <dwagner@suse.de>
Signed-off-by: Keith Busch <kbusch@kernel.org>
---
 block/genhd.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

Keith Busch Oct. 7, 2022, 7:36 p.m. UTC | #1
On Fri, Oct 07, 2022 at 12:32:34PM -0700, Keith Busch wrote:
> +	if (disk->major == BLOCK_EXT_MAJOR)
> +		blk_free_ext_minor(disk->first_minor);
>  	iput(disk->part0->bd_inode);	/* frees the disk */
>  }

Oops, the above is missing the check for the hidden flag. V2 coming.
diff mbox series

Patch

diff --git a/block/genhd.c b/block/genhd.c
index 514395361d7c..d46edf26320a 100644
--- a/block/genhd.c
+++ b/block/genhd.c
@@ -1166,6 +1166,8 @@  static void disk_release(struct device *dev)
 	if (test_bit(GD_ADDED, &disk->state) && disk->fops->free_disk)
 		disk->fops->free_disk(disk);
 
+	if (disk->major == BLOCK_EXT_MAJOR)
+		blk_free_ext_minor(disk->first_minor);
 	iput(disk->part0->bd_inode);	/* frees the disk */
 }