Skip to content

Commit

Permalink
block: reject attempts to allocate more than DISK_MAX_PARTS partitions
Browse files Browse the repository at this point in the history
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
  • Loading branch information
Christoph Hellwig authored and Jens Axboe committed Aug 23, 2017
1 parent 10433d0 commit de65b01
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions block/genhd.c
Original file line number Diff line number Diff line change
Expand Up @@ -1357,6 +1357,13 @@ struct gendisk *alloc_disk_node(int minors, int node_id)
struct gendisk *disk;
struct disk_part_tbl *ptbl;

if (minors > DISK_MAX_PARTS) {
printk(KERN_ERR
"block: can't allocated more than %d partitions\n",
DISK_MAX_PARTS);
minors = DISK_MAX_PARTS;
}

disk = kzalloc_node(sizeof(struct gendisk), GFP_KERNEL, node_id);
if (disk) {
if (!init_part_stats(&disk->part0)) {
Expand Down

0 comments on commit de65b01

Please sign in to comment.