Leaking minor device numbers

Keith Busch kbusch at kernel.org
Fri Oct 7 12:25:21 PDT 2022


On Fri, Oct 07, 2022 at 01:15:43PM -0600, Keith Busch wrote:
> 
> It sounds like the del_gendisk needs to take on this responsibility
> directly for HIDDEN disks. The below appears to work, but I'm not sure
> this is respecting the necessary dev_t lifetime if user space is holding
> a reference on the namespace.

The previous patch was indeed wrong with dev_t lifetimes. This is better:

---
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 */
 }
 
--



More information about the Linux-nvme mailing list