mtd: Raise limit on block device minor numbers
authorBen Hutchings <bhutchings@solarflare.com>
Fri, 29 Jan 2010 20:59:53 +0000 (20:59 +0000)
committerDavid Woodhouse <David.Woodhouse@intel.com>
Thu, 25 Feb 2010 12:40:19 +0000 (12:40 +0000)
add_mtd_blktrans_dev() imposes a maximum of 257 devices per block
translator.  This was presumably meant to prevent overflow back in the
days of 8-bit minor numbers.  Instead, check against MINORMASK and the
limits of the partition naming scheme.

Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
drivers/mtd/mtd_blkdevs.c

index 85a52b3c7698fdb851dfca9abb0dc33c27ef6f53..2f8c202dbd86d8fe97019d29d718fbf536a83c54 100644 (file)
@@ -242,9 +242,12 @@ int add_mtd_blktrans_dev(struct mtd_blktrans_dev *new)
        if (new->devnum == -1)
                new->devnum = last_devnum+1;
 
-       if ((new->devnum << tr->part_bits) > 256) {
+       /* Check that the device and any partitions will get valid
+        * minor numbers and that the disk naming code below can cope
+        * with this number. */
+       if (new->devnum > (MINORMASK >> tr->part_bits) ||
+           (tr->part_bits && new->devnum >= 27 * 26))
                return -EBUSY;
-       }
 
        list_add_tail(&new->list, &tr->devs);
  added: