mirror of
https://github.com/torvalds/linux.git
synced 2024-12-27 13:22:23 +00:00
block: add check of 'minors' and 'first_minor' in device_add_disk()
'first_minor' represents the starting minor number of disks, and 'minors' represents the number of partitions in the device. Neither of them can be greater than MINORMASK + 1. Commite338924bd0
("block: check minor range in device_add_disk()") only added the check of 'first_minor + minors'. However, their sum might be less than MINORMASK but their values are wrong. Complete the checks now. Fixes:e338924bd0
("block: check minor range in device_add_disk()") Signed-off-by: Li Nan <linan122@huawei.com> Reviewed-by: Christoph Hellwig <hch@lst.de> Link: https://lore.kernel.org/r/20231219075942.840255-1-linan666@huaweicloud.com Signed-off-by: Jens Axboe <axboe@kernel.dk>
This commit is contained in:
parent
6c9b97085c
commit
4c434392c4
@ -432,7 +432,9 @@ int __must_check device_add_disk(struct device *parent, struct gendisk *disk,
|
||||
DISK_MAX_PARTS);
|
||||
disk->minors = DISK_MAX_PARTS;
|
||||
}
|
||||
if (disk->first_minor + disk->minors > MINORMASK + 1)
|
||||
if (disk->first_minor > MINORMASK ||
|
||||
disk->minors > MINORMASK + 1 ||
|
||||
disk->first_minor + disk->minors > MINORMASK + 1)
|
||||
goto out_exit_elevator;
|
||||
} else {
|
||||
if (WARN_ON(disk->minors))
|
||||
|
Loading…
Reference in New Issue
Block a user