Skip to contentSkip to conversation

MTD: Prevent a read from regions[-1]

PATCH New Roel Kluin 1 participant 1 message Aug 9, 2009 Memory technology devices (MTD)

lore
Share & tools
lore

Roel Kluin

author
#0 lore raw

PATCH 1/1 MTD: Prevent a read from regions[-1]

If the erase region was found in the first iteration we read from regions[-1]

---

drivers/mtd/mtdpart.c +2 -1
index 349fcbe..a83cfa1 100644
@@ -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++) {