summaryrefslogtreecommitdiffstats
path: root/block/genhd.c
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2017-08-23 13:10:29 -0400
committerJens Axboe <axboe@kernel.dk>2017-08-23 14:49:50 -0400
commitde65b0123216a8e1dbe3ca1eb20a45572b9e71d9 (patch)
treef1c0278d6d8e18f22b42829b81e058def7ce69bc /block/genhd.c
parent10433d04b8e647a50feffec72fd3cf40ce42b084 (diff)
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>
Diffstat (limited to 'block/genhd.c')
-rw-r--r--block/genhd.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/block/genhd.c b/block/genhd.c
index 2367087cdb7c..3380a1e73ea0 100644
--- a/block/genhd.c
+++ b/block/genhd.c
@@ -1357,6 +1357,13 @@ struct gendisk *alloc_disk_node(int minors, int node_id)
1357 struct gendisk *disk; 1357 struct gendisk *disk;
1358 struct disk_part_tbl *ptbl; 1358 struct disk_part_tbl *ptbl;
1359 1359
1360 if (minors > DISK_MAX_PARTS) {
1361 printk(KERN_ERR
1362 "block: can't allocated more than %d partitions\n",
1363 DISK_MAX_PARTS);
1364 minors = DISK_MAX_PARTS;
1365 }
1366
1360 disk = kzalloc_node(sizeof(struct gendisk), GFP_KERNEL, node_id); 1367 disk = kzalloc_node(sizeof(struct gendisk), GFP_KERNEL, node_id);
1361 if (disk) { 1368 if (disk) {
1362 if (!init_part_stats(&disk->part0)) { 1369 if (!init_part_stats(&disk->part0)) {