summaryrefslogtreecommitdiff
path: root/drivers/mtd
diff options
context:
space:
mode:
authorFabian Frederick <fabf@skynet.be>2014-03-06 18:04:22 +0800
committerBrian Norris <computersforpeace@gmail.com>2014-03-10 22:42:31 -0700
commitea6d833a3fddcd1d60414d48f34c7f4fbe88608f (patch)
tree5a1bfbc1fbe161975ff3887d4625c8ab78bbf815 /drivers/mtd
parent90445ff6241e2a13445310803e2efa606c61f276 (diff)
mtd: block2mtd: check device size
fixme applied : check device size is a multiple of erasesize. Signed-off-by: Fabian Frederick <fabf@skynet.be> Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Diffstat (limited to 'drivers/mtd')
-rw-r--r--drivers/mtd/devices/block2mtd.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/drivers/mtd/devices/block2mtd.c b/drivers/mtd/devices/block2mtd.c
index 3e12234b7565..66f0405f7e53 100644
--- a/drivers/mtd/devices/block2mtd.c
+++ b/drivers/mtd/devices/block2mtd.c
@@ -209,7 +209,6 @@ static void block2mtd_free_device(struct block2mtd_dev *dev)
}
-/* FIXME: ensure that mtd->size % erase_size == 0 */
static struct block2mtd_dev *add_device(char *devname, int erase_size)
{
const fmode_t mode = FMODE_READ | FMODE_WRITE | FMODE_EXCL;
@@ -249,6 +248,11 @@ static struct block2mtd_dev *add_device(char *devname, int erase_size)
goto err_free_block2mtd;
}
+ if ((long)dev->blkdev->bd_inode->i_size % erase_size) {
+ pr_err("erasesize must be a divisor of device size\n");
+ goto err_free_block2mtd;
+ }
+
mutex_init(&dev->write_mutex);
/* Setup the MTD structure */