fix overflow checks in mtdpart

This commit is contained in:
Sebastien Lorquet 2021-11-30 16:13:17 +01:00 committed by Xiang Xiao
parent d4a5003376
commit 7f11255662

View File

@ -777,7 +777,6 @@ FAR struct mtd_dev_s *mtd_partition(FAR struct mtd_dev_s *mtd,
unsigned int blkpererase; unsigned int blkpererase;
off_t erasestart; off_t erasestart;
off_t eraseend; off_t eraseend;
off_t devblocks;
int ret; int ret;
DEBUGASSERT(mtd); DEBUGASSERT(mtd);
@ -815,8 +814,7 @@ FAR struct mtd_dev_s *mtd_partition(FAR struct mtd_dev_s *mtd,
/* Verify that the sub-region is valid for this geometry */ /* Verify that the sub-region is valid for this geometry */
devblocks = blkpererase * geo.neraseblocks; if (eraseend > geo.neraseblocks)
if (eraseend > devblocks)
{ {
ferr("ERROR: sub-region too big\n"); ferr("ERROR: sub-region too big\n");
return NULL; return NULL;