aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mtd
diff options
context:
space:
mode:
authorAtsushi Nemoto <anemo@mba.ocn.ne.jp>2008-07-18 12:01:22 -0400
committerDavid Woodhouse <David.Woodhouse@intel.com>2008-07-25 10:00:11 -0400
commitf636ffb420f0f9059c1d0b841afd691657246ad6 (patch)
treef1aaf8fedaf98f6143ea1a560c24430a14ac8def /drivers/mtd
parent6910c1368104d50e6b6afc6c8b7e9d1670a374e7 (diff)
[MTD][MTDPART] Fix a division by zero bug
When detecting a partition beyond the end of the device, skip most of the initialisation, in particular those bits causing a division by zero. Signed-off-by: Jörn Engel <joern@logfs.org> Signed-off-by: Atsushi Nemoto <anemo@mba.ocn.ne.jp> Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
Diffstat (limited to 'drivers/mtd')
-rw-r--r--drivers/mtd/mtdpart.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/drivers/mtd/mtdpart.c b/drivers/mtd/mtdpart.c
index 5aac59c21ead..edb90b58a9b1 100644
--- a/drivers/mtd/mtdpart.c
+++ b/drivers/mtd/mtdpart.c
@@ -411,11 +411,12 @@ static struct mtd_part *add_one_partition(struct mtd_info *master,
411 411
412 /* let's do some sanity checks */ 412 /* let's do some sanity checks */
413 if (slave->offset >= master->size) { 413 if (slave->offset >= master->size) {
414 /* let's register it anyway to preserve ordering */ 414 /* let's register it anyway to preserve ordering */
415 slave->offset = 0; 415 slave->offset = 0;
416 slave->mtd.size = 0; 416 slave->mtd.size = 0;
417 printk(KERN_ERR"mtd: partition \"%s\" is out of reach -- disabled\n", 417 printk(KERN_ERR"mtd: partition \"%s\" is out of reach -- disabled\n",
418 part->name); 418 part->name);
419 goto out_register;
419 } 420 }
420 if (slave->offset + slave->mtd.size > master->size) { 421 if (slave->offset + slave->mtd.size > master->size) {
421 slave->mtd.size = master->size - slave->offset; 422 slave->mtd.size = master->size - slave->offset;
@@ -475,6 +476,7 @@ static struct mtd_part *add_one_partition(struct mtd_info *master,
475 } 476 }
476 } 477 }
477 478
479out_register:
478 if (part->mtdp) { 480 if (part->mtdp) {
479 /* store the object pointer (caller may or may not register it*/ 481 /* store the object pointer (caller may or may not register it*/
480 *part->mtdp = &slave->mtd; 482 *part->mtdp = &slave->mtd;