aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/mtd/devices/docg3.c17
1 files changed, 5 insertions, 12 deletions
diff --git a/drivers/mtd/devices/docg3.c b/drivers/mtd/devices/docg3.c
index f5930caa38e7..62e01113c317 100644
--- a/drivers/mtd/devices/docg3.c
+++ b/drivers/mtd/devices/docg3.c
@@ -872,11 +872,8 @@ static int doc_read_oob(struct mtd_info *mtd, loff_t from,
872 if (ooblen % DOC_LAYOUT_OOB_SIZE) 872 if (ooblen % DOC_LAYOUT_OOB_SIZE)
873 return -EINVAL; 873 return -EINVAL;
874 874
875 ret = -EINVAL; 875 if (from + len > mtd->size)
876 calc_block_sector(from + len, &block0, &block1, &page, &ofs, 876 return -EINVAL;
877 docg3->reliable);
878 if (block1 > docg3->max_block)
879 goto err;
880 877
881 ops->oobretlen = 0; 878 ops->oobretlen = 0;
882 ops->retlen = 0; 879 ops->retlen = 0;
@@ -1207,7 +1204,7 @@ static int doc_erase(struct mtd_info *mtd, struct erase_info *info)
1207 calc_block_sector(info->addr + info->len, &block0, &block1, &page, 1204 calc_block_sector(info->addr + info->len, &block0, &block1, &page,
1208 &ofs, docg3->reliable); 1205 &ofs, docg3->reliable);
1209 ret = -EINVAL; 1206 ret = -EINVAL;
1210 if (block1 > docg3->max_block || page || ofs) 1207 if (info->addr + info->len > mtd->size || page || ofs)
1211 goto reset_err; 1208 goto reset_err;
1212 1209
1213 ret = 0; 1210 ret = 0;
@@ -1443,12 +1440,8 @@ static int doc_write_oob(struct mtd_info *mtd, loff_t ofs,
1443 if (len && ooblen && 1440 if (len && ooblen &&
1444 (len / DOC_LAYOUT_PAGE_SIZE) != (ooblen / oobdelta)) 1441 (len / DOC_LAYOUT_PAGE_SIZE) != (ooblen / oobdelta))
1445 return -EINVAL; 1442 return -EINVAL;
1446 1443 if (ofs + len > mtd->size)
1447 ret = -EINVAL; 1444 return -EINVAL;
1448 calc_block_sector(ofs + len, &block0, &block1, &page, &pofs,
1449 docg3->reliable);
1450 if (block1 > docg3->max_block)
1451 goto err;
1452 1445
1453 ops->oobretlen = 0; 1446 ops->oobretlen = 0;
1454 ops->retlen = 0; 1447 ops->retlen = 0;