Browse Source

block: reject attempts to allocate more than DISK_MAX_PARTS partitions

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Christoph Hellwig 8 years ago
parent
commit
de65b01232
1 changed files with 7 additions and 0 deletions
  1. 7 0
      block/genhd.c

+ 7 - 0
block/genhd.c

@@ -1357,6 +1357,13 @@ struct gendisk *alloc_disk_node(int minors, int node_id)
 	struct gendisk *disk;
 	struct gendisk *disk;
 	struct disk_part_tbl *ptbl;
 	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);
 	disk = kzalloc_node(sizeof(struct gendisk), GFP_KERNEL, node_id);
 	if (disk) {
 	if (disk) {
 		if (!init_part_stats(&disk->part0)) {
 		if (!init_part_stats(&disk->part0)) {