[patch 11/13] mtd: prevent a read from regions[-1]

akpm at linux-foundation.org akpm at linux-foundation.org
Fri Sep 18 15:51:50 EDT 2009


From: Roel Kluin <roel.kluin at gmail.com>

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>
Cc: David Woodhouse <dwmw2 at infradead.org>
Signed-off-by: Andrew Morton <akpm at linux-foundation.org>
---

 drivers/mtd/mtdpart.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff -puN drivers/mtd/mtdpart.c~mtd-prevent-a-read-from-regions drivers/mtd/mtdpart.c
--- a/drivers/mtd/mtdpart.c~mtd-prevent-a-read-from-regions
+++ a/drivers/mtd/mtdpart.c
@@ -453,7 +453,8 @@ static struct mtd_part *add_one_partitio
 		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 mailing list