Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 231721
b: refs/heads/master
c: 154bf89
h: refs/heads/master
i:
  231719: 1ff8d0c
v: v3
  • Loading branch information
Artem Bityutskiy authored and David Woodhouse committed Jan 17, 2011
1 parent 3921960 commit 65bac45
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 52d039fdaa78c5a9f9bc2940ad58d7ed76b8336d
refs/heads/master: 154bf89f5e3e3dc59666926f27ca4a0866f39157
19 changes: 18 additions & 1 deletion trunk/drivers/mtd/mtdpart.c
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,25 @@ static int part_read_oob(struct mtd_info *mtd, loff_t from,
return -EINVAL;
if (ops->datbuf && from + ops->len > mtd->size)
return -EINVAL;
res = part->master->read_oob(part->master, from + part->offset, ops);

/*
* If OOB is also requested, make sure that we do not read past the end
* of this partition.
*/
if (ops->oobbuf) {
size_t len, pages;

if (ops->mode == MTD_OOB_AUTO)
len = mtd->oobavail;
else
len = mtd->oobsize;
pages = mtd_div_by_ws(mtd->size, mtd);
pages -= mtd_div_by_ws(from, mtd);
if (ops->ooboffs + ops->ooblen > pages * len)
return -EINVAL;
}

res = part->master->read_oob(part->master, from + part->offset, ops);
if (unlikely(res)) {
if (res == -EUCLEAN)
mtd->ecc_stats.corrected++;
Expand Down

0 comments on commit 65bac45

Please sign in to comment.