Skip to content

Commit d027951

Browse files
ISCAS-Vulabmiquelraynal
authored andcommitted
mtd: inftlcore: Add error check for inftl_read_oob()
In INFTL_findwriteunit(), the return value of inftl_read_oob() need to be checked. A proper implementation can be found in INFTL_deleteblock(). The status will be set as SECTOR_IGNORE to break from the while-loop correctly if the inftl_read_oob() fails. Fixes: 8593fbc ("[MTD] Rework the out of band handling completely") Cc: stable@vger.kernel.org # v2.6+ Signed-off-by: Wentao Liang <vulab@iscas.ac.cn> Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
1 parent 36c6468 commit d027951

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

drivers/mtd/inftlcore.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -482,10 +482,11 @@ static inline u16 INFTL_findwriteunit(struct INFTLrecord *inftl, unsigned block)
482482
silly = MAX_LOOPS;
483483

484484
while (thisEUN <= inftl->lastEUN) {
485-
inftl_read_oob(mtd, (thisEUN * inftl->EraseSize) +
486-
blockofs, 8, &retlen, (char *)&bci);
487-
488-
status = bci.Status | bci.Status1;
485+
if (inftl_read_oob(mtd, (thisEUN * inftl->EraseSize) +
486+
blockofs, 8, &retlen, (char *)&bci) < 0)
487+
status = SECTOR_IGNORE;
488+
else
489+
status = bci.Status | bci.Status1;
489490
pr_debug("INFTL: status of block %d in EUN %d is %x\n",
490491
block , writeEUN, status);
491492

0 commit comments

Comments
 (0)