]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
mtd: nand: fix error handling in nand_prog_page_op() #1
authorSascha Hauer <s.hauer@pengutronix.de>
Fri, 5 Feb 2021 14:27:24 +0000 (15:27 +0100)
committerMiquel Raynal <miquel.raynal@bootlin.com>
Thu, 11 Mar 2021 08:37:29 +0000 (09:37 +0100)
On success chip->legacy.waitfunc() returns the NAND status byte, but on
failure it returns a negative error code. This was never tested for and
instead the return value was interpreted as NAND status without error
checking. Add the missing error check.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20210205142725.13225-1-s.hauer@pengutronix.de
drivers/mtd/nand/raw/nand_base.c

index 4e1bd1e5d474aaaa0b6e352d29f594c2f7638b88..878492fbb52a46f2ba62f69c3342b1fed7804d53 100644 (file)
@@ -1466,6 +1466,8 @@ int nand_prog_page_op(struct nand_chip *chip, unsigned int page,
                chip->legacy.write_buf(chip, buf, len);
                chip->legacy.cmdfunc(chip, NAND_CMD_PAGEPROG, -1, -1);
                status = chip->legacy.waitfunc(chip);
+               if (status < 0)
+                       return status;
        }
 
        if (status & NAND_STATUS_FAIL)