Skip to content

Commit

Permalink
mtd: Raise limit on block device minor numbers
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: Artem Bityutskiy <[email protected]>
Signed-off-by: David Woodhouse <[email protected]>
  • Loading branch information
Ben Hutchings authored and David Woodhouse committed Feb 25, 2010
1 parent b520e41 commit 4d3a853
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions drivers/mtd/mtd_blkdevs.c
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 4d3a853

Please sign in to comment.