Skip to contentSkip to conversation

MTD: Prevent a read from eraseregions[-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 eraseregions[-1]

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

---

drivers/mtd/mtdconcat.c +3 -3
index 792b547..db6de74 100644
@@ -427,7 +427,7 @@ static int concat_erase(struct mtd_info *mtd, struct erase_info *instr)
 		 * to-be-erased area begins. Verify that the starting
 		 * offset is aligned to this region's erase size:
 		 */
-		if (instr->addr & (erase_regions[i].erasesize - 1))
+		if (i < 0 || instr->addr & (erase_regions[i].erasesize - 1))
 			return -EINVAL;
 
 		/*
@@ -440,8 +440,8 @@ static int concat_erase(struct mtd_info *mtd, struct erase_info *instr)
 		/*
 		 * check if the ending offset is aligned to this region's erase size
 		 */
-		if ((instr->addr + instr->len) & (erase_regions[i].erasesize -
-						  1))
+		if (i < 0 || ((instr->addr + instr->len) &
+					(erase_regions[i].erasesize - 1)))
 			return -EINVAL;
 	}