Skip to contentSkip to conversation

block: fix leaking minors of hidden disks

PATCH Superseded Keith Busch 2 participants 2 messages Oct 7, 2022 Block layer

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 block: fix leaking minors of hidden disks

From: Keith Busch <[email protected]>

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.

---
 block/genhd.c | 2 ++
 1 file changed, 2 insertions(+)
block/genhd.c +2 -0
index 514395361d7c..d46edf26320a 100644
@@ -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 */
 }
 
Signature · 1 line
2.30.2
#1 lore raw

block/genhd.c static void disk_release(struct device *dev) · line 1172

Quoted 4 lines · Keith Busch
block/genhd.c +2 -0
+	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.