mirror of
https://github.com/edk2-porting/linux-next.git
synced 2024-12-24 13:13:57 +08:00
block: fix leaking minors of hidden disks
The major/minor of a hidden gendisk is not propagated to the block
device because it is never registered using bdev_add. But the lack of
bd_dev also causes the dynamic major minor number not to be freed.
Assign bd_dev manually to ensure the dynamic major minor gets freed.
Based on a patch by Keith Busch.
Fixes: 8ddcd65325
("block: introduce GENHD_FL_HIDDEN")
Reported-by: Daniel Wagner <dwagner@suse.de>
Signed-off-by: Christoph Hellwig <hch@lst.de>
Tested-by: Daniel Wagner <dwagner@suse.de>
Reviewed-by: Keith Busch <kbusch@kernel.org>
Link: https://lore.kernel.org/r/20221010131857.748129-1-hch@lst.de
Signed-off-by: Jens Axboe <axboe@kernel.dk>
This commit is contained in:
parent
ca5eebda3e
commit
a0a6314ae7
@ -507,6 +507,13 @@ int __must_check device_add_disk(struct device *parent, struct gendisk *disk,
|
|||||||
*/
|
*/
|
||||||
dev_set_uevent_suppress(ddev, 0);
|
dev_set_uevent_suppress(ddev, 0);
|
||||||
disk_uevent(disk, KOBJ_ADD);
|
disk_uevent(disk, KOBJ_ADD);
|
||||||
|
} else {
|
||||||
|
/*
|
||||||
|
* Even if the block_device for a hidden gendisk is not
|
||||||
|
* registered, it needs to have a valid bd_dev so that the
|
||||||
|
* freeing of the dynamic major works.
|
||||||
|
*/
|
||||||
|
disk->part0->bd_dev = MKDEV(disk->major, disk->first_minor);
|
||||||
}
|
}
|
||||||
|
|
||||||
disk_update_readahead(disk);
|
disk_update_readahead(disk);
|
||||||
|
Loading…
Reference in New Issue
Block a user