diff options
-rw-r--r-- | drivers/block/nbd.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c index 1df3bfe5225b..fdee7567fd15 100644 --- a/drivers/block/nbd.c +++ b/drivers/block/nbd.c | |||
@@ -757,6 +757,12 @@ static int __init nbd_init(void) | |||
757 | if (max_part > 0) | 757 | if (max_part > 0) |
758 | part_shift = fls(max_part); | 758 | part_shift = fls(max_part); |
759 | 759 | ||
760 | if ((1UL << part_shift) > DISK_MAX_PARTS) | ||
761 | return -EINVAL; | ||
762 | |||
763 | if (nbds_max > 1UL << (MINORBITS - part_shift)) | ||
764 | return -EINVAL; | ||
765 | |||
760 | for (i = 0; i < nbds_max; i++) { | 766 | for (i = 0; i < nbds_max; i++) { |
761 | struct gendisk *disk = alloc_disk(1 << part_shift); | 767 | struct gendisk *disk = alloc_disk(1 << part_shift); |
762 | if (!disk) | 768 | if (!disk) |