diff options
Diffstat (limited to 'drivers/block/loop.c')
-rw-r--r-- | drivers/block/loop.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/drivers/block/loop.c b/drivers/block/loop.c index a076a14ca72d..c59a672a3de0 100644 --- a/drivers/block/loop.c +++ b/drivers/block/loop.c | |||
@@ -1658,7 +1658,7 @@ static struct kobject *loop_probe(dev_t dev, int *part, void *data) | |||
1658 | struct kobject *kobj; | 1658 | struct kobject *kobj; |
1659 | 1659 | ||
1660 | mutex_lock(&loop_devices_mutex); | 1660 | mutex_lock(&loop_devices_mutex); |
1661 | lo = loop_init_one(dev & MINORMASK); | 1661 | lo = loop_init_one(MINOR(dev) >> part_shift); |
1662 | kobj = lo ? get_disk(lo->lo_disk) : ERR_PTR(-ENOMEM); | 1662 | kobj = lo ? get_disk(lo->lo_disk) : ERR_PTR(-ENOMEM); |
1663 | mutex_unlock(&loop_devices_mutex); | 1663 | mutex_unlock(&loop_devices_mutex); |
1664 | 1664 | ||
@@ -1691,15 +1691,18 @@ static int __init loop_init(void) | |||
1691 | if (max_part > 0) | 1691 | if (max_part > 0) |
1692 | part_shift = fls(max_part); | 1692 | part_shift = fls(max_part); |
1693 | 1693 | ||
1694 | if ((1UL << part_shift) > DISK_MAX_PARTS) | ||
1695 | return -EINVAL; | ||
1696 | |||
1694 | if (max_loop > 1UL << (MINORBITS - part_shift)) | 1697 | if (max_loop > 1UL << (MINORBITS - part_shift)) |
1695 | return -EINVAL; | 1698 | return -EINVAL; |
1696 | 1699 | ||
1697 | if (max_loop) { | 1700 | if (max_loop) { |
1698 | nr = max_loop; | 1701 | nr = max_loop; |
1699 | range = max_loop; | 1702 | range = max_loop << part_shift; |
1700 | } else { | 1703 | } else { |
1701 | nr = 8; | 1704 | nr = 8; |
1702 | range = 1UL << (MINORBITS - part_shift); | 1705 | range = 1UL << MINORBITS; |
1703 | } | 1706 | } |
1704 | 1707 | ||
1705 | if (register_blkdev(LOOP_MAJOR, "loop")) | 1708 | if (register_blkdev(LOOP_MAJOR, "loop")) |
@@ -1738,7 +1741,7 @@ static void __exit loop_exit(void) | |||
1738 | unsigned long range; | 1741 | unsigned long range; |
1739 | struct loop_device *lo, *next; | 1742 | struct loop_device *lo, *next; |
1740 | 1743 | ||
1741 | range = max_loop ? max_loop : 1UL << (MINORBITS - part_shift); | 1744 | range = max_loop ? max_loop << part_shift : 1UL << MINORBITS; |
1742 | 1745 | ||
1743 | list_for_each_entry_safe(lo, next, &loop_devices, lo_list) | 1746 | list_for_each_entry_safe(lo, next, &loop_devices, lo_list) |
1744 | loop_del_one(lo); | 1747 | loop_del_one(lo); |