Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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: 8593fbc68b0d ("[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>

authored by

Wentao Liang and committed by
Miquel Raynal
d027951d 36c64687

+5 -4
+5 -4
drivers/mtd/inftlcore.c
··· 482 482 silly = MAX_LOOPS; 483 483 484 484 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; 489 490 pr_debug("INFTL: status of block %d in EUN %d is %x\n", 490 491 block , writeEUN, status); 491 492