mtd: mtdpart: prevent a read from regions[-1]

Linux-MTD Mailing List linux-mtd at lists.infradead.org
Sat Sep 19 14:59:03 EDT 2009


Gitweb:     http://git.infradead.org/?p=mtd-2.6.git;a=commit;h=a57ca0466af5da83e379d636b8c01fd53b41e2c6
Commit:     a57ca0466af5da83e379d636b8c01fd53b41e2c6
Parent:     ebf2e93036907fe2a7ddab942aa63d35f97f3b2b
Author:     Roel Kluin <roel.kluin at gmail.com>
AuthorDate: Fri Sep 18 12:51:50 2009 -0700
Committer:  David Woodhouse <David.Woodhouse at intel.com>
CommitDate: Sat Sep 19 11:23:26 2009 -0700

    mtd: mtdpart: prevent a read from regions[-1]
    
    If the erase region was found in the first iteration we read from
    regions[-1]
    
    Signed-off-by: Roel Kluin <roel.kluin at gmail.com>
    Signed-off-by: Andrew Morton <akpm at linux-foundation.org>
    Signed-off-by: David Woodhouse <David.Woodhouse at intel.com>
---
 drivers/mtd/mtdpart.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/drivers/mtd/mtdpart.c b/drivers/mtd/mtdpart.c
index 349fcbe..a83cfa1 100644
--- a/drivers/mtd/mtdpart.c
+++ b/drivers/mtd/mtdpart.c
@@ -453,7 +453,8 @@ static struct mtd_part *add_one_partition(struct mtd_info *master,
 		for (i = 0; i < max && regions[i].offset <= slave->offset; i++)
 			;
 		/* The loop searched for the region _behind_ the first one */
-		i--;
+		if (i > 0)
+			i--;
 
 		/* Pick biggest erasesize */
 		for (; i < max && regions[i].offset < end; i++) {



More information about the linux-mtd-cvs mailing list