]> err.no Git - linux-2.6/commitdiff
[MTD][MTDPART] Fix a division by zero bug
authorAtsushi Nemoto <anemo@mba.ocn.ne.jp>
Fri, 18 Jul 2008 16:01:22 +0000 (01:01 +0900)
committerDavid Woodhouse <David.Woodhouse@intel.com>
Fri, 25 Jul 2008 14:00:11 +0000 (10:00 -0400)
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>
drivers/mtd/mtdpart.c

index 5aac59c21ead8a8769cb3e4e08f773d8cecdc10b..edb90b58a9b16980bd42066f6026bbd1ca7c0667 100644 (file)
@@ -411,11 +411,12 @@ static struct mtd_part *add_one_partition(struct mtd_info *master,
 
        /* let's do some sanity checks */
        if (slave->offset >= master->size) {
-                       /* let's register it anyway to preserve ordering */
+               /* let's register it anyway to preserve ordering */
                slave->offset = 0;
                slave->mtd.size = 0;
                printk(KERN_ERR"mtd: partition \"%s\" is out of reach -- disabled\n",
                        part->name);
+               goto out_register;
        }
        if (slave->offset + slave->mtd.size > master->size) {
                slave->mtd.size = master->size - slave->offset;
@@ -475,6 +476,7 @@ static struct mtd_part *add_one_partition(struct mtd_info *master,
                }
        }
 
+out_register:
        if (part->mtdp) {
                /* store the object pointer (caller may or may not register it*/
                *part->mtdp = &slave->mtd;