mtd: Raise limit on block device minor numbers

Linux-MTD Mailing List linux-mtd at lists.infradead.org
Thu Feb 25 07:59:05 EST 2010


Gitweb:     http://git.infradead.org/?p=mtd-2.6.git;a=commit;h=4d3a8534bdbcf4843fc8ad05c9a81a964fc65237
Commit:     4d3a8534bdbcf4843fc8ad05c9a81a964fc65237
Parent:     b520e412faaaad35641aeedd6059179f9f1b393c
Author:     Ben Hutchings <bhutchings at solarflare.com>
AuthorDate: Fri Jan 29 20:59:53 2010 +0000
Committer:  David Woodhouse <David.Woodhouse at intel.com>
CommitDate: Thu Feb 25 12:40:19 2010 +0000

    mtd: Raise limit on block device minor numbers
    
    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 at solarflare.com>
    Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy at nokia.com>
    Signed-off-by: David Woodhouse <David.Woodhouse at intel.com>
---
 drivers/mtd/mtd_blkdevs.c |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/mtd/mtd_blkdevs.c b/drivers/mtd/mtd_blkdevs.c
index 85a52b3..2f8c202 100644
--- a/drivers/mtd/mtd_blkdevs.c
+++ b/drivers/mtd/mtd_blkdevs.c
@@ -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:



More information about the linux-mtd-cvs mailing list