Skip to content

Commit

Permalink
mtd: nand: check the return code of 'read_oob/read_oob_raw'
Browse files Browse the repository at this point in the history
Apparently, there is an implementor of 'read_oob' which may return an
error inidication (e.g. docg4_read_oob may return -EIO).

Test the return value of 'read_oob/read_oob_raw', and if negative,
propagate the error, so it's returned by the '_read_oob' interface.

Signed-off-by: Shmulik Ladkani <[email protected]>
Signed-off-by: Artem Bityutskiy <[email protected]>
Signed-off-by: David Woodhouse <[email protected]>
  • Loading branch information
sladkani authored and David Woodhouse committed May 14, 2012
1 parent 5c2ffb1 commit 1951f2f
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions drivers/mtd/nand/nand_base.c
Original file line number Diff line number Diff line change
Expand Up @@ -1791,6 +1791,7 @@ static int nand_do_read_oob(struct mtd_info *mtd, loff_t from,
int readlen = ops->ooblen;
int len;
uint8_t *buf = ops->oobbuf;
int ret = 0;

pr_debug("%s: from = 0x%08Lx, len = %i\n",
__func__, (unsigned long long)from, readlen);
Expand Down Expand Up @@ -1826,9 +1827,12 @@ static int nand_do_read_oob(struct mtd_info *mtd, loff_t from,

while (1) {
if (ops->mode == MTD_OPS_RAW)
chip->ecc.read_oob_raw(mtd, chip, page);
ret = chip->ecc.read_oob_raw(mtd, chip, page);
else
chip->ecc.read_oob(mtd, chip, page);
ret = chip->ecc.read_oob(mtd, chip, page);

if (ret < 0)
break;

len = min(len, readlen);
buf = nand_transfer_oob(chip, buf, ops, len);
Expand Down Expand Up @@ -1857,7 +1861,10 @@ static int nand_do_read_oob(struct mtd_info *mtd, loff_t from,
}
}

ops->oobretlen = ops->ooblen;
ops->oobretlen = ops->ooblen - readlen;

if (ret < 0)
return ret;

if (mtd->ecc_stats.failed - stats.failed)
return -EBADMSG;
Expand Down

0 comments on commit 1951f2f

Please sign in to comment.