[MTD][MTDPART] Fix a division by zero bug

Linux-MTD Mailing List linux-mtd at lists.infradead.org
Fri Jul 25 10:59:02 EDT 2008


Gitweb:     http://git.infradead.org/?p=mtd-2.6.git;a=commit;h=f636ffb420f0f9059c1d0b841afd691657246ad6
Commit:     f636ffb420f0f9059c1d0b841afd691657246ad6
Parent:     6910c1368104d50e6b6afc6c8b7e9d1670a374e7
Author:     Atsushi Nemoto <anemo at mba.ocn.ne.jp>
AuthorDate: Sat Jul 19 01:01:22 2008 +0900
Committer:  David Woodhouse <David.Woodhouse at intel.com>
CommitDate: Fri Jul 25 10:00:11 2008 -0400

    [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 at logfs.org>
    Signed-off-by: Atsushi Nemoto <anemo at mba.ocn.ne.jp>
    Signed-off-by: David Woodhouse <David.Woodhouse at intel.com>
---
 drivers/mtd/mtdpart.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/drivers/mtd/mtdpart.c b/drivers/mtd/mtdpart.c
index 5aac59c..edb90b5 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,
 
 	/* 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;



More information about the linux-mtd-cvs mailing list